Skip to content

Instantly share code, notes, and snippets.

@qmx
Created August 7, 2010 13:14
Show Gist options
  • Save qmx/512802 to your computer and use it in GitHub Desktop.
Save qmx/512802 to your computer and use it in GitHub Desktop.
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "192.168.144.17:1099");
InitialContext ic = new InitialContext(env);
TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) ic.lookup("ConnectionFactory");
TopicConnection topicConnection = topicConnectionFactory.createTopicConnection();
TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
TextMessage textMessage = topicSession.createTextMessage();
textMessage.setText("dolar: " +new Random().nextDouble()+"");
Topic topic = (Topic) ic.lookup("topic/testTopic");
TopicPublisher topicPublisher = topicSession.createPublisher(topic);
topicPublisher.publish(textMessage);
System.out.println("Foi");
<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
name="jboss.mq:service=JMSProviderLoader,name=RemoteJMSProvider,server=remotehost">
<attribute name="ProviderName">RemoteJMSProvider</attribute>
<attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
<!-- The connection factory -->
<attribute name="FactoryRef">UIL2XAConnectionFactory</attribute>
<!-- The queue connection factory -->
<attribute name="QueueFactoryRef">UIL2XAConnectionFactory</attribute>
<!-- The topic factory -->
<attribute name="TopicFactoryRef">UIL2XAConnectionFactory</attribute>
<!-- Connect to JNDI on the host "the-remote-host-name" port 1099-->
<attribute name="Properties">
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jnp.interfaces
java.naming.provider.url=192.168.144.17:1099
</attribute>
</mbean>
@ActivationConfigProperty(propertyName="providerAdapterJNDI", propertyValue="java:/RemoteJMSProvider")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment