You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by sandeep reddy <sa...@in2m.com> on 2008/06/20 19:02:20 UTC

help with JMSConsumer message selector?

I have servicemix-camel 3.2.2 snapshot in my ServiceMix 3.2.1 instance.

I need to implement JMS Consumer which subscribe to a topic but only accept
a message based on selection criteria specified in messageSelector. My
message contains a property which is a List object containing String
elements. My JMS consumer need to accept a message based on the contents in
the List. I am not able to figure out how to write a message selection
criteria for it in a single string. I have implemented similar logic in
Camel in Java using header("userPrincipals").contains("portal") but not sure
on how to what to set in message selector.

Please advice.

Thanks in advance,
Sandeep Reddy


-- 
View this message in context: http://www.nabble.com/help-with-JMSConsumer-message-selector--tp18033749p18033749.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: help with JMSConsumer message selector?

Posted by sandeep reddy <sa...@in2m.com>.
Issue: Message properties not being sent as part of JMS message added to a
queue or topic. After searching on JIRA we found that this may have been due
to changes to implementation of JMS endpoints (SM-510)

We are setting message properties in a normalized message which is then sent
to a JMS topic. JMS subscribers to the topic consume message based on
message selector. But as the properties set in normalized message are
stripped during converting it to a JMS message the messages are not
consumed. We have created a custom JMS Provider Marshaller which is actually
a merge between the current
org.apache.servicemix.jms.endpoints.DefaultProviderMarshaler and
org.apache.servicemix.components.jms.JmsMarshaler.

We think this should be the default behavior of the
DefaultProviderMarshaller and hence decided to post it on forum. ServiceMix
committers can decide if they want to include the patch.

Regards,
Sandeep

http://www.nabble.com/file/p18214389/DefaultProviderMarshaler.java
DefaultProviderMarshaler.java 

sandeep reddy wrote:
> 
> 
> Hi,
>     
>     Is that something getting confusing details provided or else should i
> need to provider more 
> details on these?
> 
>      It's just the question :
> 
>           when message went to topic i noticed that there is no any
> properties (using JCONSOLE) ? how 
> to get rid of this problem?
> 
> Thanks,
> Sandeep.
> 
> 
> 
> sandeep reddy wrote:
>> 
>> Hi Gert,
>> 
>>     Thanks for replying.
>>      I tried your solution for iterating the set and and creating a
>> comma-separated string.
>> 
>>     Application Flow:
>> 
>>     Bean-SU --> Camel-SU ---> JMSProvider-SU(Topic) ---> JMSConsumer-SU
>> 
>> 
>>     In above flow, Bean-SU creating the comma-separated string and sets
>> this as a property for the message. Camel-Su forwards the message to
>> JMSProvider (Topic).
>> 
>>     Messages in the topic do not contain any properties (observed using
>> JCONSOLE).
>> 
>>     So my JMSConsumer is not able to consume any message, since
>> messageSelector criteria never matches.
>> 
>>     Camel SU:
>>     <route>
>>       <from
>> uri="jbi:service:http://servicemix.in2m.com/operations/updateprofile/routingService"/>
>>       <to
>> uri="jbi:service:http://servicemix.in2m.com/operations/updateprofile/JMSProviderService?mep=in-only"/>
>>     </route>
>> 
>>     JMSConsumerSU:
>> 
>>           <jms:consumer service="hello:JMSConsumerService"
>>                   endpoint="DirectorConsumer"
>>                     targetService="hello:DirectorService"
>>                   pubSubDomain="true"
>>                   destinationName="updateUserProfileTopic"
>>                   connectionFactory="#connectionFactory"
>>                   messageSelector="userPrincipals LIKE '%smx1%'" />
>>    
>>    
>>    plz help me?
>> 
>> Sandeep
>> 
>> 
>> Gert Vanthienen wrote:
>>> 
>>> Sandeep Reddy,
>>> 
>>> I don't think that is possible with JMS Message selector syntax.  It 
>>> does have an IN keyword like SQL, but that one only takes a collection 
>>> of String literals.  There as some examples of what you can do in 
>>> http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java?revision=408638.
>>> 
>>> For your use case, you could expand the list of userPrincipals in a 
>>> comma-separated syntax and use the LIKE expression syntax go check it.
>>> 
>>> Regards,
>>> 
>>> Gert
>>> 
>>> sandeep reddy wrote:
>>>> I have servicemix-camel 3.2.2 snapshot in my ServiceMix 3.2.1 instance.
>>>>
>>>> I need to implement JMS Consumer which subscribe to a topic but only
>>>> accept
>>>> a message based on selection criteria specified in messageSelector. My
>>>> message contains a property which is a List object containing String
>>>> elements. My JMS consumer need to accept a message based on the
>>>> contents in
>>>> the List. I am not able to figure out how to write a message selection
>>>> criteria for it in a single string. I have implemented similar logic in
>>>> Camel in Java using header("userPrincipals").contains("portal") but not
>>>> sure
>>>> on how to what to set in message selector.
>>>>
>>>> Please advice.
>>>>
>>>> Thanks in advance,
>>>> Sandeep Reddy
>>>>
>>>>
>>>>   
>>> 
>>> 
>>> 
>>> -----
>>> ---
>>> Gert Vanthienen
>>> http://www.anova.be
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/help-with-JMSConsumer-message-selector--tp18033749p18214389.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: help with JMSConsumer message selector?

Posted by sandeep reddy <sa...@in2m.com>.

Hi,
    
    Is that something getting confusing details provided or else should i
need to provider more 
details on these?

     It's just the question :

          when message went to topic i noticed that there is no any
properties (using JCONSOLE) ? how 
to get rid of this problem?

Thanks,
Sandeep.



sandeep reddy wrote:
> 
> Hi Gert,
> 
>     Thanks for replying.
>      I tried your solution for iterating the set and and creating a
> comma-separated string.
> 
>     Application Flow:
> 
>     Bean-SU --> Camel-SU ---> JMSProvider-SU(Topic) ---> JMSConsumer-SU
> 
> 
>     In above flow, Bean-SU creating the comma-separated string and sets
> this as a property for the message. Camel-Su forwards the message to
> JMSProvider (Topic).
> 
>     Messages in the topic do not contain any properties (observed using
> JCONSOLE).
> 
>     So my JMSConsumer is not able to consume any message, since
> messageSelector criteria never matches.
> 
>     Camel SU:
>     <route>
>       <from
> uri="jbi:service:http://servicemix.in2m.com/operations/updateprofile/routingService"/>
>       <to
> uri="jbi:service:http://servicemix.in2m.com/operations/updateprofile/JMSProviderService?mep=in-only"/>
>     </route>
> 
>     JMSConsumerSU:
> 
>           <jms:consumer service="hello:JMSConsumerService"
>                   endpoint="DirectorConsumer"
>                     targetService="hello:DirectorService"
>                   pubSubDomain="true"
>                   destinationName="updateUserProfileTopic"
>                   connectionFactory="#connectionFactory"
>                   messageSelector="userPrincipals LIKE '%smx1%'" />
>    
>    
>    plz help me?
> 
> Sandeep
> 
> 
> Gert Vanthienen wrote:
>> 
>> Sandeep Reddy,
>> 
>> I don't think that is possible with JMS Message selector syntax.  It 
>> does have an IN keyword like SQL, but that one only takes a collection 
>> of String literals.  There as some examples of what you can do in 
>> http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java?revision=408638.
>> 
>> For your use case, you could expand the list of userPrincipals in a 
>> comma-separated syntax and use the LIKE expression syntax go check it.
>> 
>> Regards,
>> 
>> Gert
>> 
>> sandeep reddy wrote:
>>> I have servicemix-camel 3.2.2 snapshot in my ServiceMix 3.2.1 instance.
>>>
>>> I need to implement JMS Consumer which subscribe to a topic but only
>>> accept
>>> a message based on selection criteria specified in messageSelector. My
>>> message contains a property which is a List object containing String
>>> elements. My JMS consumer need to accept a message based on the contents
>>> in
>>> the List. I am not able to figure out how to write a message selection
>>> criteria for it in a single string. I have implemented similar logic in
>>> Camel in Java using header("userPrincipals").contains("portal") but not
>>> sure
>>> on how to what to set in message selector.
>>>
>>> Please advice.
>>>
>>> Thanks in advance,
>>> Sandeep Reddy
>>>
>>>
>>>   
>> 
>> 
>> 
>> -----
>> ---
>> Gert Vanthienen
>> http://www.anova.be
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/help-with-JMSConsumer-message-selector--tp18033749p18110201.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: help with JMSConsumer message selector?

Posted by sandeep reddy <sa...@in2m.com>.
Hi Gert,

    Thanks for replying.
     I tried your solution for iterating the set and and creating a
comma-separated string.

    Application Flow:

    Bean-SU --> Camel-SU ---> JMSProvider-SU(Topic) ---> JMSConsumer-SU


    In above flow, Bean-SU creating the comma-separated string and sets this
as a property for the message. Camel-Su forwards the message to JMSProvider
(Topic).

    Messages in the topic do not contain any properties (observed using
JCONSOLE).

    So my JMSConsumer is not able to consume any message, since
messageSelector criteria never matches.

    Camel SU:
    <route>
      <from
uri="jbi:service:http://servicemix.in2m.com/operations/updateprofile/routingService"/>
      <to
uri="jbi:service:http://servicemix.in2m.com/operations/updateprofile/JMSProviderService?mep=in-only"/>
    </route>

    JMSConsumerSU:

          <jms:consumer service="hello:JMSConsumerService"
                  endpoint="DirectorConsumer"
                    targetService="hello:DirectorService"
                  pubSubDomain="true"
                  destinationName="updateUserProfileTopic"
                  connectionFactory="#connectionFactory"
                  messageSelector="userPrincipals LIKE '%smx1%'" />
   
   
   plz help me?

Sandeep


Gert Vanthienen wrote:
> 
> Sandeep Reddy,
> 
> I don't think that is possible with JMS Message selector syntax.  It 
> does have an IN keyword like SQL, but that one only takes a collection 
> of String literals.  There as some examples of what you can do in 
> http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java?revision=408638.
> 
> For your use case, you could expand the list of userPrincipals in a 
> comma-separated syntax and use the LIKE expression syntax go check it.
> 
> Regards,
> 
> Gert
> 
> sandeep reddy wrote:
>> I have servicemix-camel 3.2.2 snapshot in my ServiceMix 3.2.1 instance.
>>
>> I need to implement JMS Consumer which subscribe to a topic but only
>> accept
>> a message based on selection criteria specified in messageSelector. My
>> message contains a property which is a List object containing String
>> elements. My JMS consumer need to accept a message based on the contents
>> in
>> the List. I am not able to figure out how to write a message selection
>> criteria for it in a single string. I have implemented similar logic in
>> Camel in Java using header("userPrincipals").contains("portal") but not
>> sure
>> on how to what to set in message selector.
>>
>> Please advice.
>>
>> Thanks in advance,
>> Sandeep Reddy
>>
>>
>>   
> 
> 
> 
> -----
> ---
> Gert Vanthienen
> http://www.anova.be
> 

-- 
View this message in context: http://www.nabble.com/help-with-JMSConsumer-message-selector--tp18033749p18084149.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: help with JMSConsumer message selector?

Posted by Gert Vanthienen <ge...@skynet.be>.
Sandeep Reddy,

I don't think that is possible with JMS Message selector syntax.  It 
does have an IN keyword like SQL, but that one only takes a collection 
of String literals.  There as some examples of what you can do in 
http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java?revision=408638.

For your use case, you could expand the list of userPrincipals in a 
comma-separated syntax and use the LIKE expression syntax go check it.

Regards,

Gert

sandeep reddy wrote:
> I have servicemix-camel 3.2.2 snapshot in my ServiceMix 3.2.1 instance.
>
> I need to implement JMS Consumer which subscribe to a topic but only accept
> a message based on selection criteria specified in messageSelector. My
> message contains a property which is a List object containing String
> elements. My JMS consumer need to accept a message based on the contents in
> the List. I am not able to figure out how to write a message selection
> criteria for it in a single string. I have implemented similar logic in
> Camel in Java using header("userPrincipals").contains("portal") but not sure
> on how to what to set in message selector.
>
> Please advice.
>
> Thanks in advance,
> Sandeep Reddy
>
>
>