You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Timothy Bish (JIRA)" <ji...@apache.org> on 2015/04/20 15:24:59 UTC

[jira] [Comment Edited] (AMQ-5732) Changing message selector leads to blocking message

    [ https://issues.apache.org/jira/browse/AMQ-5732?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14502272#comment-14502272 ] 

Timothy Bish edited comment on AMQ-5732 at 4/20/15 1:24 PM:
------------------------------------------------------------

The message receive function is like this (ignoring creating connection part):

{code}

	public BlobMessage getMedia(String fileName) throws JMSException{
		try {
			ActiveMQSession fileSession = (ActiveMQSession) connection.createSession(true, ActiveMQSession.CLIENT_ACKNOWLEDGE);
			Destination destinationMedia = fileSession.createQueue("MediaQueue");
			MessageConsumer consumerFile = fileSession.createConsumer(destinationMedia,"FileName='"+ fileName + "'");
			Message bmsg = consumerFile.receive(60000);
			BlobMessage blobMessage = (BlobMessage) bmsg;
			if (null != blobMessage) {
				bmsg.acknowledge();
				fileSession.commit();
				fileSession.close();				
				fileSession = (ActiveMQSession) connection.createSession(true, ActiveMQSession.CLIENT_ACKNOWLEDGE);
				destinationMedia = fileSession.createQueue("MediaQueue");
				MessageProducer produceFile = fileSession.createProducer(destinationMedia);
				produceFile.send(bmsg);
				produceFile.close();
			}
			consumerFile.close();
			fileSession.rollback();
			fileSession.close();
			return blobMessage;			
		} catch (JMSException e) {
			throw e;
		}		
	}

{code}

and in the main function :

BlobMessage bmsg = client.getMedia("scriptset123.zip");  

the code works fine, but then if I change the filename to "script456.zip" (which is exist in the queue),and run the code again. the consumer is blocked 60s. 
If I restart the activeMQ, and run the code with  "script456.zip", it works. but if I change to "scriptset123.zip" and rerun the code, the consumer is blocked again.



was (Author: cadmean):
The message receive function is like this (ignoring creating connection part):

	public BlobMessage getMedia(String fileName) throws JMSException{
		try {
			ActiveMQSession fileSession = (ActiveMQSession) connection.createSession(true, ActiveMQSession.CLIENT_ACKNOWLEDGE);
			Destination destinationMedia = fileSession.createQueue("MediaQueue");
			MessageConsumer consumerFile = fileSession.createConsumer(destinationMedia,"FileName='"+ fileName + "'");
			Message bmsg = consumerFile.receive(60000);
			BlobMessage blobMessage = (BlobMessage) bmsg;
			if (null != blobMessage) {
				bmsg.acknowledge();
				fileSession.commit();
				fileSession.close();				
				fileSession = (ActiveMQSession) connection.createSession(true, ActiveMQSession.CLIENT_ACKNOWLEDGE);
				destinationMedia = fileSession.createQueue("MediaQueue");
				MessageProducer produceFile = fileSession.createProducer(destinationMedia);
				produceFile.send(bmsg);
				produceFile.close();
			}
			consumerFile.close();
			fileSession.rollback();
			fileSession.close();
			return blobMessage;			
		} catch (JMSException e) {
			throw e;
		}		
	}

and in the main function :

BlobMessage bmsg = client.getMedia("scriptset123.zip");  

the code works fine, but then if I change the filename to "script456.zip" (which is exist in the queue),and run the code again. the consumer is blocked 60s. 
If I restart the activeMQ, and run the code with  "script456.zip", it works. but if I change to "scriptset123.zip" and rerun the code, the consumer is blocked again.


> Changing message selector leads to blocking message
> ---------------------------------------------------
>
>                 Key: AMQ-5732
>                 URL: https://issues.apache.org/jira/browse/AMQ-5732
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker, JMS client
>    Affects Versions: 5.11.1
>         Environment: Suse Linux 11 sp2
>            Reporter: Cadmean
>              Labels: features
>
> The problem is:
> 1. I create a queue in activemq broker (version 5.11.1) and some message with string property, for example "filename".
> 2. Use a client to consume the message with message selector "filename='123.tar'" with consumer.receive(),it works.  After it receive the message, it acks the message and send the same message back to the broker and commit the session. (client_acknowledge). 
> 3. Use the same client, change the message selector to "filename='456.tar'" with consumer.receive(), the consumer is blocked. 
> 4. restart the broker and consumer "filename='456.tar'" again, it successfully receive the message, but if i change the selector back to "filename='123.tar'", it blocked again.
> At first I thought that there might be some rules for message dispatching. However, with ActiveMQ version 5.10.0, the problem is gone.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)