Spring integrating with remote Topic

Hi,
I am going to demonstrate how to receive messages from a remote topic.

The remote Topic is placed in a Jboss application server.

1. Add topic implementation jars into spring lib class-path

2. We going to create jmsTemplate makes the java code pretty minimal and simple:

public class TgwMDB implements MessageListener
{

	@Override
	public void onMessage(Message msg)
	{
	}
}

3. Most of the configuration is at the applicationContextXml:

3.1 Declare jmsTemplate:

 	jnp://server.ip:1099
	org.jnp.interfaces.NamingContextFactory
	org.jboss.naming:org.jnp.interfaces

3.2 declare jndiTopicConnFactory.

	

3.3 declare ConnectionFactory:


3.4. declare DestinationResolver:

3.5 declare DefaultMessageListenerContainer which will act as a cached message listener

		 // this property pubSubDomain turns the listener from Queue to Topic.

 


You ready now to receive messages.

Idan.

[ad]

Related Articles:

(1801)

Ejb Injection to Spring from Jboss

Hi,

Here is how we lookup from Spring to jboss:

So let’s say we have Interface implemented in jboss:

com.DestBean

The jndi loopup: /DestBean/remote.

in Spring side:

1. Create a bean which trigger the method:

public class TriggerBean
{
	@Autowired
	DestBean destBean;

	public void test()
	{
		boolean result = destBean.setSomething(1, 2);
		System.out.println("the result is="+  result);
	}
}

Now let’s configure applicationContext.xml:




	
		
		java.naming.provider.url">serverhost:port
		java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
		java.naming.factory.url.pkgs=jboss.naming:org.jnp.interfaces
		
	

pay attention that business-interface attribute should have the value of the class-path of your remote interface placed in the target server.

And that’s it!

Idan.

[ad]

Related Articles:

(1801)