You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by cafe <rm...@estudiantes.uci.cu> on 2007/02/16 20:48:39 UTC

I can’t receive more than 2 messages simultaneously with DefaultMessageListenerContainer

I have an app where I’m using spring 2.0 and activeMQ4.1.0. In this app I
need to process many message and send files to another queue, all this
simultaneously, so I have configured a DefaultMessageListenerContainer in
this way:

 
	<bean id="updateContainer" 
	  
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
		<property name="concurrentConsumers" value="50" />
		<property name="connectionFactory" ref="jmsFactory" />
		<property name="destination" ref="requestUpdateQueue" />
		<property name="messageListener" ref="requestUpdateListener" />
	</bean>



Buy the problem is that when the clients increase more than 2, the
transferring is stopped.

Could be this a bug?

Regards…

-- 
View this message in context: http://www.nabble.com/I-can%E2%80%99t-receive-more-than-2-messages-simultaneously-with-DefaultMessageListenerContainer-tf3241539s2354.html#a9011209
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: I can’t receive more than 2 messages simultaneously with DefaultMessageListenerContainer

Posted by cafe <rm...@estudiantes.uci.cu>.
to add more, the server stop without any exception...
-- 
View this message in context: http://www.nabble.com/I-can%E2%80%99t-receive-more-than-2-messages-simultaneously-with-DefaultMessageListenerContainer-tf3241539s2354.html#a9016908
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: I can’t receive more than 2 messages simultaneously with DefaultMessageListenerContainer

Posted by cafe <rm...@estudiantes.uci.cu>.
sorry for the bare explanation. 

I have a listener (in the server side) who receive request for send files
(Streams):

public class RequestUpdateListener implements SessionAwareMessageListener {

	private JmsTemplate jmsTemplate;

	private String fileUpdateLocation;
	
	public void onMessage(Message request, Session session) throws JMSException
{


		ActiveMQConnectionFactory connectionFactory = ((PooledConnectionFactory)
jmsTemplate
				.getConnectionFactory()).getConnectionFactory();

		FileInputStream fis = null;
		try {
			fis = new FileInputStream(new File(fileUpdateLocation));
			StreamSender ss = new StreamSender();
			ss.send(connectionFactory, fis,uuid);

		} catch (Exception e) {
			e.printStackTrace();
		}
	
	}
.............

and a class:

public class StreamSender {

	public void send(ConnectionFactory connectionFactory, FileInputStream fis,
String uuid) {
		
		try {

			connection = (ActiveMQConnection) connectionFactory.createConnection();
			session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
			Destination destination = session.createQueue("TransferQueue");

			int deliveryMode = DeliveryMode.NON_PERSISTENT;
			int priority = 1;
			long timeToLive = 0;

			outputStreamMQ = connection.createOutputStream(destination, prop,
deliveryMode, priority,
					timeToLive);

		
			int total = 0;
			int reads;
			byte[] array = new byte[8 * 1024];

			while ((reads = fis.read(array)) != -1) {
				outputStreamMQ.write(array, 0, reads);
			}

			JmsUtils.commitIfNecessary(session);
......

and again the spring container:

	<bean id="updateContainer"
		class="org.springframework.jms.listener.DefaultMessageListenerContainer">
		<property name="concurrentConsumers" value="50" />
		<property name="connectionFactory" ref="jmsFactory" />
		<property name="destination" ref="requestUpdateQueue" />
		<property name="messageListener" ref="requestUpdateListener" />
	</bean>


 
and in the client side I have a listener who receive the Stream:

public class NotificationListener implements SessionAwareMessageListener {


	public void onMessage(Message response, Session session) throws
JMSException {

		String message = "xml descriptor";
		jmsTemplate.convertAndSend(requestUpdateQueue, message, new
MessagePostProcessor() {
			public Message postProcessMessage(Message message) throws JMSException {
				....
				return message;
			}
		});
		
		StreamReceiver receiver = new StreamReceiver();
		receiver.setConnectionFactory(connectionFactory);
		receiver.receive();

	}

public class StreamReceiver {


	public void receive() {
		...
		try {

			connection = (ActiveMQConnection) connectionFactory.createConnection();
			session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
			Destination destination = session.createQueue("TransferQueue");
			fisMQ = connection.createInputStream(destination, selector);
			fos = new FileOutputStream("...");

                        int reads;
			int total = 0;
			byte[] array = new byte[8 * 1024];

			while ((reads = fisMQ.read(array)) != -1) {
				fos.write(array, 0, reads);
				total += reads;
					}
			JmsUtils.commitIfNecessary(session);
.........

Now the problem arise when more than 2 client running in different machines
does a request simultaneously, the server (StreamSender) stop the transfer

what could be this?

-- 
View this message in context: http://www.nabble.com/I-can%E2%80%99t-receive-more-than-2-messages-simultaneously-with-DefaultMessageListenerContainer-tf3241539s2354.html#a9016161
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: I can’t receive more than 2 messages simultaneously with DefaultMessageListenerContainer

Posted by Paul French <pa...@frenchiesystems.com>.
You need to give more info since it is not clear what you are trying to do.

The Listener Container you have configured will start 50 threads all waiting
to consume messages.

Give more info and I will be happy to help.


cafe wrote:
> 
> I have an app where I’m using spring 2.0 and activeMQ4.1.0. In this app I
> need to process many message and send files to another queue, all this
> simultaneously, so I have configured a DefaultMessageListenerContainer in
> this way:
> 
>  
> 	<bean id="updateContainer" 
> 	  
> class="org.springframework.jms.listener.DefaultMessageListenerContainer">
> 		<property name="concurrentConsumers" value="50" />
> 		<property name="connectionFactory" ref="jmsFactory" />
> 		<property name="destination" ref="requestUpdateQueue" />
> 		<property name="messageListener" ref="requestUpdateListener" />
> 	</bean>
> 
> 
> 
> Buy the problem is that when the clients increase more than 2, the
> transferring is stopped.
> 
> Could be this a bug?
> 
> Regards…
> 
> 

-- 
View this message in context: http://www.nabble.com/I-can%E2%80%99t-receive-more-than-2-messages-simultaneously-with-DefaultMessageListenerContainer-tf3241539s2354.html#a9015235
Sent from the ActiveMQ - User mailing list archive at Nabble.com.