You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "ritesh (JIRA)" <ji...@apache.org> on 2013/10/09 21:06:42 UTC

[jira] [Commented] (AMQ-4793) issue with messageSelector

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

ritesh commented on AMQ-4793:
-----------------------------

Thanks for the reply.

Ok, I will use receive(timeout), but my problem is it's not guaranty that every time when i ask for message(with messageSelector) message will be there.
So, take below same example if my messageSelector is "JMSCorrelationID = '4544'", now there is no match for this selector and using .receive(1000). 
Consumer will wait for 1000ms unnecessary. Which does impact on my performance any other way i can use messageSelector and didn't wait for amount of time specified with receive (if message is not there). This problem occurs only if no match messageSelector.   


> issue with messageSelector
> --------------------------
>
>                 Key: AMQ-4793
>                 URL: https://issues.apache.org/jira/browse/AMQ-4793
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>            Reporter: ritesh
>
> Having issue with message selector.
> Message is already there in queue (I can confirm with activeMQ browser app). 
> Create consumer with messageSelector and do consumer.receiveNoWait() always receive NULL message.
> Have only three message in queue.
> code sample...
> try
>            {
>             
>             ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
>             Connection connection= connectionFactory.createConnection();
>             connection.start();
>             Session session= connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
>             Destination queueDestination = session.createQueue("TestQueue");
>              //using activeMq browser app i can see message is there with JMSCorrelationID=12345 
>              String messageSelector= "JMSCorrelationID = '12345'";
>              MessageConsumer consumer= session.createConsumer(queueDestination,messageSelector);
>              Message message= consumer.receiveNoWait();
>              if(message==null)
>              {
>                  // always return null message
>                  //log message not found
>              }
>                
>            }
>            catch (Exception e)
>            {
>            }
> But, if do this it’s works …
> For(int i=0; i< 7; i++)
> {
> 	Thread.sleep(100);
> message= consumer.receiveNoWait();	
> 	If(message!=null)
> 		Break;
> }
> please help me what am i doing wrong?



--
This message was sent by Atlassian JIRA
(v6.1#6144)