You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by apara <ap...@standardset.com> on 2014/07/02 17:04:18 UTC
How do I pair @Consume with @Produce on an interface?
Using Camel 2.13.1
So, I have defined a @Produce on an interface, which appears to be producing
messages correctly (verified via logging):
public interface Producer extends CriteriaServiceObserver {
@InOnly
void created(CriteriaDocument criteria, Map state);
@InOnly
void updated(CriteriaDocument criteria, Map state);
@InOnly
void beforeDelete(CriteriaDocument criteria, Map state);
@InOnly
void afterDelete(CriteriaDocument criteria, Map state);
}
@Produce(uri = "direct://criteria.event")
private Producer
jmsEventProducer;
Elsewhere, I am trying to consume these messages:
@Component
public class SampleGroupWatcherServiceImpl implements
CriteriaServiceObserver {
...
@Override
@Consume(uri = "direct://criteria.event")
public void created(final CriteriaDocument criteria, final Map state) {
LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria created");
}
@Override
@Consume(uri = "direct://criteria.event")
public void updated(final CriteriaDocument criteria, final Map state) {
LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria updated");
}
@Override
@Consume(uri = "direct://criteria.event")
public void beforeDelete(final CriteriaDocument criteria, final Map
state) {
LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria before delete");
}
@Override
@Consume(uri = "direct://criteria.event")
public void afterDelete(final CriteriaDocument criteria, final Map
state) {
LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria after delete");
}
...
However, the exception I get from Camel is:
java.lang.IllegalArgumentException: Cannot add a 2nd consumer to the same
endpoint. Endpoint Endpoint[direct://criteria.event] only allows one
consumer.
I am trying to "remote" and interface via Camel/ActiveMQ. So, my intent is
to have one box make the API call, message queued onto the Queue, and
another box de-queue and process the message.
I am sure I am doing something wrong as the @Produce part seems to be
working correctly. I am just stuck at the @Consume.
Thanks.
--
View this message in context: http://camel.465427.n5.nabble.com/How-do-I-pair-Consume-with-Produce-on-an-interface-tp5753215.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How do I pair @Consume with @Produce on an interface?
Posted by apara <ap...@standardset.com>.
So, still sticking with an interface, and trying to make each method put a
message on a different queue, I made these change:
@InOnly
public interface Producer extends CriteriaServiceObserver {
@InOnly
@Produce(uri = "direct://criteria.created.event")
void created(CriteriaDocument criteria, Map state);
@InOnly
@Produce(uri = "direct://criteria.updated.event")
void updated(CriteriaDocument criteria, Map state);
@InOnly
@Produce(uri = "direct://criteria.beforeDelete.event")
void beforeDelete(CriteriaDocument criteria, Map state);
@InOnly
@Produce(uri = "direct://criteria.afterDelete.event")
void afterDelete(CriteriaDocument criteria, Map state);
}
@Produce
private Producer
jmsEventProducer;
However, now, jmsEventProducer is not initialized and remains null.
I guess, I am really trying to avoid making multiple producer interfaces and
then tying them together in yet another component that simply implements my
observer and forwards the calls to these individual @Provider interfaces.
I noticed that @Produce can be applied to methods, but not quite sure how
that should work as I have not seen any examples of that yet.
Thanks.
-AP_
--
View this message in context: http://camel.465427.n5.nabble.com/How-do-I-pair-Consume-with-Produce-on-an-interface-tp5753215p5753217.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How do I pair @Consume with @Produce on an interface?
Posted by apara <ap...@standardset.com>.
Thanks for your help.
I found exactly what I wanted to (by reading those links on the bottom of
the page) with Spring Remoting using Camel's extensions. For some reason,
I thought that @Produce and @Consume would do something similar.
On Wed, Jul 2, 2014 at 10:12 AM, Claus Ibsen-2 [via Camel] <
ml-node+s465427n5753221h14@n5.nabble.com> wrote:
> Hi
>
> There is a pojo example at
> http://camel.apache.org/pojo-messaging-example.html
>
> And see the links in the bottom of that page too.
>
> On Wed, Jul 2, 2014 at 5:04 PM, apara <[hidden email]
> <http://user/SendEmail.jtp?type=node&node=5753221&i=0>> wrote:
>
> > Using Camel 2.13.1
> >
> > So, I have defined a @Produce on an interface, which appears to be
> producing
> > messages correctly (verified via logging):
> >
> > public interface Producer extends CriteriaServiceObserver {
> > @InOnly
> > void created(CriteriaDocument criteria, Map state);
> >
> > @InOnly
> > void updated(CriteriaDocument criteria, Map state);
> >
> > @InOnly
> > void beforeDelete(CriteriaDocument criteria, Map state);
> >
> > @InOnly
> > void afterDelete(CriteriaDocument criteria, Map state);
> > }
> >
> > @Produce(uri = "direct://criteria.event")
> > private Producer
> > jmsEventProducer;
> >
> >
> > Elsewhere, I am trying to consume these messages:
> >
> > @Component
> > public class SampleGroupWatcherServiceImpl implements
> > CriteriaServiceObserver {
> >
> > ...
> >
> > @Override
> > @Consume(uri = "direct://criteria.event")
> > public void created(final CriteriaDocument criteria, final Map
> state) {
> > LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria created");
> > }
> >
> > @Override
> > @Consume(uri = "direct://criteria.event")
> > public void updated(final CriteriaDocument criteria, final Map
> state) {
> > LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria updated");
> > }
> >
> > @Override
> > @Consume(uri = "direct://criteria.event")
> > public void beforeDelete(final CriteriaDocument criteria, final Map
> > state) {
> > LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria before
> delete");
> > }
> >
> > @Override
> > @Consume(uri = "direct://criteria.event")
> > public void afterDelete(final CriteriaDocument criteria, final Map
> > state) {
> > LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria after
> delete");
> > }
> >
> > ...
> >
> > However, the exception I get from Camel is:
> >
> > java.lang.IllegalArgumentException: Cannot add a 2nd consumer to the
> same
> > endpoint. Endpoint Endpoint[direct://criteria.event] only allows one
> > consumer.
> >
> >
> >
> > I am trying to "remote" and interface via Camel/ActiveMQ. So, my intent
> is
> > to have one box make the API call, message queued onto the Queue, and
> > another box de-queue and process the message.
> >
> > I am sure I am doing something wrong as the @Produce part seems to be
> > working correctly. I am just stuck at the @Consume.
> >
> > Thanks.
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/How-do-I-pair-Consume-with-Produce-on-an-interface-tp5753215.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=5753221&i=1>
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/How-do-I-pair-Consume-with-Produce-on-an-interface-tp5753215p5753221.html
> To unsubscribe from How do I pair @Consume with @Produce on an
> interface?, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5753215&code=YXBhcmFAc3RhbmRhcmRzZXQuY29tfDU3NTMyMTV8LTU0MjY3MDkwOQ==>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://camel.465427.n5.nabble.com/How-do-I-pair-Consume-with-Produce-on-an-interface-tp5753215p5753235.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How do I pair @Consume with @Produce on an interface?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
There is a pojo example at
http://camel.apache.org/pojo-messaging-example.html
And see the links in the bottom of that page too.
On Wed, Jul 2, 2014 at 5:04 PM, apara <ap...@standardset.com> wrote:
> Using Camel 2.13.1
>
> So, I have defined a @Produce on an interface, which appears to be producing
> messages correctly (verified via logging):
>
> public interface Producer extends CriteriaServiceObserver {
> @InOnly
> void created(CriteriaDocument criteria, Map state);
>
> @InOnly
> void updated(CriteriaDocument criteria, Map state);
>
> @InOnly
> void beforeDelete(CriteriaDocument criteria, Map state);
>
> @InOnly
> void afterDelete(CriteriaDocument criteria, Map state);
> }
>
> @Produce(uri = "direct://criteria.event")
> private Producer
> jmsEventProducer;
>
>
> Elsewhere, I am trying to consume these messages:
>
> @Component
> public class SampleGroupWatcherServiceImpl implements
> CriteriaServiceObserver {
>
> ...
>
> @Override
> @Consume(uri = "direct://criteria.event")
> public void created(final CriteriaDocument criteria, final Map state) {
> LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria created");
> }
>
> @Override
> @Consume(uri = "direct://criteria.event")
> public void updated(final CriteriaDocument criteria, final Map state) {
> LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria updated");
> }
>
> @Override
> @Consume(uri = "direct://criteria.event")
> public void beforeDelete(final CriteriaDocument criteria, final Map
> state) {
> LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria before delete");
> }
>
> @Override
> @Consume(uri = "direct://criteria.event")
> public void afterDelete(final CriteriaDocument criteria, final Map
> state) {
> LOG.debug(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Criteria after delete");
> }
>
> ...
>
> However, the exception I get from Camel is:
>
> java.lang.IllegalArgumentException: Cannot add a 2nd consumer to the same
> endpoint. Endpoint Endpoint[direct://criteria.event] only allows one
> consumer.
>
>
>
> I am trying to "remote" and interface via Camel/ActiveMQ. So, my intent is
> to have one box make the API call, message queued onto the Queue, and
> another box de-queue and process the message.
>
> I am sure I am doing something wrong as the @Produce part seems to be
> working correctly. I am just stuck at the @Consume.
>
> Thanks.
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-do-I-pair-Consume-with-Produce-on-an-interface-tp5753215.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/