You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by daelliott <my...@outlook.com> on 2016/06/23 12:47:09 UTC

Help with Camel Config routing using a custom ActiveMQ Message Property

I've taken over a project in which everyone that knows anything is gone.  
I'm new to ActiveMQ and have never used Camel before.  
I'm trying to do content message routing and have a sample of what I'm 
attempting to do but have a couple of questions.

* How to access a custom ActiveMQ message property.
   Is what I have below correct?

* How to trash a message  i.e. send to /dev/null

This is what I have after going through all the documentation that I could
find.
Any help is GREATLY appreciated.







--
View this message in context: http://activemq.2283324.n4.nabble.com/Help-with-Camel-Config-routing-using-a-custom-ActiveMQ-Message-Property-tp4713278.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Help with Camel Config routing using a custom ActiveMQ Message Property

Posted by Quinn Stevenson <qu...@pronoia-solutions.com>.
I had a similar use case in the past, and I chose to route the "trash"
messages to a JMS Topic that didn't have any durable subscribers.  That way
I could create a subscriber when I needed it to see what was being
"trashed" - just be careful you don't create a durable subscriber or the
messages will build-up in that topic.

On Thu, Jun 23, 2016 at 7:09 PM, Tim Bain <tb...@alumni.duke.edu> wrote:

> To trash a message, do not send it to a DLQ!  DLQ != /dev/null.
>
> Instead, just ack the message after you consume it (without doing anything
> in response, just end the route or have your processor return null), which
> in the default Camel configuration happens automatically when your Camel
> route receives the message.  If your route is somehow set up for individual
> acks, you'd have to do the ack manually, but the code you've inherited
> would have an example of what to do if that were the case.
>
> Tim
> On Jun 23, 2016 8:14 AM, "Hassen Bennour" <be...@gmail.com>
> wrote:
>
> > Hello,
> >
> > You can route messages following messages properties with filtered
> > destinations  http://activemq.apache.org/virtual-destinations.html
> > or camel  http://activemq.apache.org/sample-camel-routes.html
> > http://camel.apache.org/message-filter.html
> >
> > to trash a message i think you can route it to DLQ or another "trash
> queue"
> > or simply if it not correspond to any filtered Destination selector or
> > route it will not been forwarded, loosed.
> >
> > for example :
> > <destinationInterceptors>
> > <virtualDestinationInterceptor>
> > <virtualDestinations>
> > <compositeTopic  name="TOPIC">
> > <forwardTo>
> > * <!-- 1. all messages will be duplicated to topic TOPIC_LOGS -->*
> > <topic physicalName="TOPIC_LOGS" />
> > * <!-- 2. all messages with message property clientID = 'activemq'  will
> be
> > duplicated to topic ACTIVEMQ -->*
> > <filteredDestination selector="clientID = 'activemq'" topic="ACTIVEMQ" />
> > </forwardTo>
> > </compositeTopic >
> > </virtualDestinations>
> > </virtualDestinationInterceptor>
> > </destinationInterceptors>
> >
> > if you remove the filter 1 and a if a message dont have a *clientID =
> > 'activemq' * it will be ignored.
> >
> >
> >
> > Kind regards.
> >
> > *BENNOUR HASSEN*
> >
> > *SOA **Architect **/ **Java **Software Engineer*
> >
> > 2016-06-23 14:47 GMT+02:00 daelliott <my...@outlook.com>:
> >
> > > I've taken over a project in which everyone that knows anything is
> gone.
> > > I'm new to ActiveMQ and have never used Camel before.
> > > I'm trying to do content message routing and have a sample of what I'm
> > > attempting to do but have a couple of questions.
> > >
> > > * How to access a custom ActiveMQ message property.
> > >    Is what I have below correct?
> > >
> > > * How to trash a message  i.e. send to /dev/null
> > >
> > > This is what I have after going through all the documentation that I
> > could
> > > find.
> > > Any help is GREATLY appreciated.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://activemq.2283324.n4.nabble.com/Help-with-Camel-Config-routing-using-a-custom-ActiveMQ-Message-Property-tp4713278.html
> > > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> > >
> >
>



-- 
Quinn Stevenson
quinn@pronoia-solutions.com
(801) 244-7758

Re: Help with Camel Config routing using a custom ActiveMQ Message Property

Posted by daelliott <my...@outlook.com>.
Thank you everyone for the help.

I'm posting my config encase anyone else is searching for a 
similar solution or I need to do this again in the future.
This was developed using ActiveMQ 5.9.1

I change the names of things before posting but have verified 
this config is working as expected. I commented out the "to" as they 
are not required for what I need but once again does work if 
uncommenting.

Cheers








--
View this message in context: http://activemq.2283324.n4.nabble.com/Help-with-Camel-Config-routing-using-a-custom-ActiveMQ-Message-Property-tp4713278p4713418.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Help with Camel Config routing using a custom ActiveMQ Message Property

Posted by Quinn Stevenson <qu...@pronoia-solutions.com>.
No - Camel don’t have a “/dev/null” endpoint.  However, if you don’t want the message to go anywhere, just don’t send it (i.e. bypass the to).  If you really need the to, you can always send it to a log uri - something like <to uri="log:com.mycompany.order?level=TRACE”/>.  Then you can configure the logging system to not log that category (or to log it to another file, etc).

The access to the header looks OK - I normally use something like ${header[FirstProperty]}, but that’s just me.  Also, sometimes I’ve had to use “simple” in the expression as well or the property placeholder system get’s confused - i.e. $simple{header[FirstProperty]}

> On Jun 24, 2016, at 5:22 AM, daelliott <my...@outlook.com> wrote:
> 
> ${in.header.FirstProperty}='msgType1'


Re: Help with Camel Config routing using a custom ActiveMQ Message Property

Posted by Tim Bain <tb...@alumni.duke.edu>.
A JMS message has to be acked to remove it from its queue or topic.  Since
you have two queues, if a message goes to both queues you need to ack the
copy from each queue.  If it only goes to the first queue, you only need to
ack it there.

The default acknowledgement mode is AUTO_ACK, where the message is
automatically acknowledged when it is first delivered to you (before you
have processed it), and that's the mode it sounds like your Camel route is
using.  So the message is acknowledged when it exits your from tag, and if
you want to drop it, you just need to not route it onward to the second
queue.  So you should test the message for your criteria of which messages
you want to process, and conditionally route to the to tag (if the message
passes) or end the route without routing the message anywhere (if it
fails).  Or instead do what Quinn suggested and route to a new topic with
no consumers in the second case, so you can wiretap in when necessary.

Tim
On Jun 24, 2016 6:03 AM, "daelliott" <my...@outlook.com> wrote:

> Currently the configuration is just pulling from a remote queue to a local
> queue and that is it.
> The Camel XML config file just has a FROM and TO XML tag.
> Some changes are being made upstream that will send messages to my system
> that I may not want.
> That is the reason for wanting this filtering.
>
> The DLQ is currently used if the message can't process so we can do some
> root analysis on it and fix it.
>
> The consuming executable application of the local queue is set to
> Individual
> ACKs of messages.
> How the messages are ACK'ed from the remote server I don't know as there is
> only the "from" and "to" tags.
> You mentioned to ACK the message after consuming it. I'm guessing you meant
> in the consuming executable application.
> If you did, I was hoping to get the message from the remote server and
> filter it out before having it hit the persistent
> storage in ActiveMQ and that way the consuming application doesn't have to
> deal with it at all.
>
> From some of the responses and what I have found online, the following seem
> to be true
>   * There is no /dev/null or anything remotely related - I have to route
> the
> message somewhere I create
>   * I have to create something to process that queue in some fashion to
> clear it out
>
> Could someone address the retrieving of the property?
> Does that look right?
>    <simple>${in.header.FirstProperty}='msgType1'</simple>
>
> Thanks
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Help-with-Camel-Config-routing-using-a-custom-ActiveMQ-Message-Property-tp4713278p4713313.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Re: Help with Camel Config routing using a custom ActiveMQ Message Property

Posted by daelliott <my...@outlook.com>.
Currently the configuration is just pulling from a remote queue to a local
queue and that is it.
The Camel XML config file just has a FROM and TO XML tag.
Some changes are being made upstream that will send messages to my system
that I may not want.
That is the reason for wanting this filtering.

The DLQ is currently used if the message can't process so we can do some
root analysis on it and fix it.

The consuming executable application of the local queue is set to Individual
ACKs of messages. 
How the messages are ACK'ed from the remote server I don't know as there is
only the "from" and "to" tags.  
You mentioned to ACK the message after consuming it. I'm guessing you meant
in the consuming executable application.  
If you did, I was hoping to get the message from the remote server and
filter it out before having it hit the persistent 
storage in ActiveMQ and that way the consuming application doesn't have to
deal with it at all.

From some of the responses and what I have found online, the following seem
to be true
  * There is no /dev/null or anything remotely related - I have to route the
message somewhere I create
  * I have to create something to process that queue in some fashion to
clear it out 

Could someone address the retrieving of the property?
Does that look right?  
   <simple>${in.header.FirstProperty}='msgType1'</simple>

Thanks




--
View this message in context: http://activemq.2283324.n4.nabble.com/Help-with-Camel-Config-routing-using-a-custom-ActiveMQ-Message-Property-tp4713278p4713313.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Help with Camel Config routing using a custom ActiveMQ Message Property

Posted by Tim Bain <tb...@alumni.duke.edu>.
To trash a message, do not send it to a DLQ!  DLQ != /dev/null.

Instead, just ack the message after you consume it (without doing anything
in response, just end the route or have your processor return null), which
in the default Camel configuration happens automatically when your Camel
route receives the message.  If your route is somehow set up for individual
acks, you'd have to do the ack manually, but the code you've inherited
would have an example of what to do if that were the case.

Tim
On Jun 23, 2016 8:14 AM, "Hassen Bennour" <be...@gmail.com> wrote:

> Hello,
>
> You can route messages following messages properties with filtered
> destinations  http://activemq.apache.org/virtual-destinations.html
> or camel  http://activemq.apache.org/sample-camel-routes.html
> http://camel.apache.org/message-filter.html
>
> to trash a message i think you can route it to DLQ or another "trash queue"
> or simply if it not correspond to any filtered Destination selector or
> route it will not been forwarded, loosed.
>
> for example :
> <destinationInterceptors>
> <virtualDestinationInterceptor>
> <virtualDestinations>
> <compositeTopic  name="TOPIC">
> <forwardTo>
> * <!-- 1. all messages will be duplicated to topic TOPIC_LOGS -->*
> <topic physicalName="TOPIC_LOGS" />
> * <!-- 2. all messages with message property clientID = 'activemq'  will be
> duplicated to topic ACTIVEMQ -->*
> <filteredDestination selector="clientID = 'activemq'" topic="ACTIVEMQ" />
> </forwardTo>
> </compositeTopic >
> </virtualDestinations>
> </virtualDestinationInterceptor>
> </destinationInterceptors>
>
> if you remove the filter 1 and a if a message dont have a *clientID =
> 'activemq' * it will be ignored.
>
>
>
> Kind regards.
>
> *BENNOUR HASSEN*
>
> *SOA **Architect **/ **Java **Software Engineer*
>
> 2016-06-23 14:47 GMT+02:00 daelliott <my...@outlook.com>:
>
> > I've taken over a project in which everyone that knows anything is gone.
> > I'm new to ActiveMQ and have never used Camel before.
> > I'm trying to do content message routing and have a sample of what I'm
> > attempting to do but have a couple of questions.
> >
> > * How to access a custom ActiveMQ message property.
> >    Is what I have below correct?
> >
> > * How to trash a message  i.e. send to /dev/null
> >
> > This is what I have after going through all the documentation that I
> could
> > find.
> > Any help is GREATLY appreciated.
> >
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://activemq.2283324.n4.nabble.com/Help-with-Camel-Config-routing-using-a-custom-ActiveMQ-Message-Property-tp4713278.html
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
>

Re: Help with Camel Config routing using a custom ActiveMQ Message Property

Posted by Hassen Bennour <be...@gmail.com>.
Hello,

You can route messages following messages properties with filtered
destinations  http://activemq.apache.org/virtual-destinations.html
or camel  http://activemq.apache.org/sample-camel-routes.html
http://camel.apache.org/message-filter.html

to trash a message i think you can route it to DLQ or another "trash queue"
or simply if it not correspond to any filtered Destination selector or
route it will not been forwarded, loosed.

for example :
<destinationInterceptors>
<virtualDestinationInterceptor>
<virtualDestinations>
<compositeTopic  name="TOPIC">
<forwardTo>
* <!-- 1. all messages will be duplicated to topic TOPIC_LOGS -->*
<topic physicalName="TOPIC_LOGS" />
* <!-- 2. all messages with message property clientID = 'activemq'  will be
duplicated to topic ACTIVEMQ -->*
<filteredDestination selector="clientID = 'activemq'" topic="ACTIVEMQ" />
</forwardTo>
</compositeTopic >
</virtualDestinations>
</virtualDestinationInterceptor>
</destinationInterceptors>

if you remove the filter 1 and a if a message dont have a *clientID =
'activemq' * it will be ignored.



Kind regards.

*BENNOUR HASSEN*

*SOA **Architect **/ **Java **Software Engineer*

2016-06-23 14:47 GMT+02:00 daelliott <my...@outlook.com>:

> I've taken over a project in which everyone that knows anything is gone.
> I'm new to ActiveMQ and have never used Camel before.
> I'm trying to do content message routing and have a sample of what I'm
> attempting to do but have a couple of questions.
>
> * How to access a custom ActiveMQ message property.
>    Is what I have below correct?
>
> * How to trash a message  i.e. send to /dev/null
>
> This is what I have after going through all the documentation that I could
> find.
> Any help is GREATLY appreciated.
>
>
>
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Help-with-Camel-Config-routing-using-a-custom-ActiveMQ-Message-Property-tp4713278.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>