You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Jason Vinson <vi...@charter.net> on 2006/03/20 16:37:14 UTC
Best Way to Start out with ServiceMix
Hi,
I'm very new to servicemix, but I have a question about what is the
best approach to start writing "service engines" to use in a
servicemix esb. My first thought is to write a class that extends
PojoSupport and implements MessageExchangeListener, but I wanted to
find out from the experts if this is the desired implementation.
I've also been drawn towards the TransformComponentSupport class,
which I suppose could be used to plug in a service as well, but the
name implies that it's to be used for transformation, not service
execution. Could I get some info regarding this, or at least
pointers to a clear tutorial on this concept?
Thanks so much,
Jason
Re: Best Way to Start out with ServiceMix
Posted by Jason Vinson <vi...@charter.net>.
Perhaps I should give an example of what i am seeing here...
I have the following class that I am using to try out servicemix and
the attached servicemix.xml
package org.vinson.servicemix;
/** omitting imports **/
public class ServiceMixPassthroughProxy extends PojoSupport
implements MessageExchangeListener {
public void onMessageExchange(MessageExchange exchange) throws
MessagingException {
System.out.println("Got Message");
done(exchange);
}
}
I get the following in the console:
ServiceMix ESB: 2.0.2
Loading ServiceMix from file: src/conf/servicemix.xml
Created MBeanServer with ID: d22104:10a1979e58c:-8000:oriza.local:1
RMIConnectorServer started at: service:jmx:rmi://oriza.local/jndi/
rmi://localhost:1099/defaultJBIJMX
Got Message
Why don't i see any output in my output directory? If i take my
"custom" MessageExchangeListener out of the flow, it writes the file
out to the file system, but not if this class is present.
Again, any pointers would be appreciated,
Jason

On Mar 20, 2006, at 10:37 AM, Jason Vinson wrote:
> Hi,
>
> I'm very new to servicemix, but I have a question about what is the
> best approach to start writing "service engines" to use in a
> servicemix esb. My first thought is to write a class that extends
> PojoSupport and implements MessageExchangeListener, but I wanted to
> find out from the experts if this is the desired implementation.
>
> I've also been drawn towards the TransformComponentSupport class,
> which I suppose could be used to plug in a service as well, but the
> name implies that it's to be used for transformation, not service
> execution. Could I get some info regarding this, or at least
> pointers to a clear tutorial on this concept?
>
> Thanks so much,
> Jason
Re: Best Way to Start out with ServiceMix
Posted by Guillaume Nodet <gn...@gmail.com>.
Yes, that's they way to do it.
I think your problem using send is due to the fact that you have to
check the exchange status when you receive an exchange.
If you send (not sendSync) an InOnly exchange, you will receive the
same exchange with a DONE status.
Try something like
public void onMessageExhcange(MessageExchange exchange) {
if (exchange.getStatus() == ExchangeStatus.DONE) {
return;
} else if (exchange.getStatus() == ExchangeStatus.ERROR) {
return;
}
...
}
Cheers,
Guillaume Nodet
On 3/21/06, Jason Vinson <vi...@charter.net> wrote:
> I found a way to do this that i think is correct. The following is
> what i came up with (parts borrowed from ScriptComponent):
>
> public void onMessageExchange(MessageExchange exchange)
> throws MessagingException {
> NormalizedMessage in = exchange.getMessage("in");
> Object payload = getBody(in);
>
> // do something with it...
> processPayload(payload);
>
> if (isInAndOut(exchange)) {
> NormalizedMessage out = exchange.createMessage();
> exchange.setMessage(out, "out");
> } else {
> InOnly outExchange = getExchangeFactory().createInOnlyExchange();
> NormalizedMessage out = outExchange.createMessage();
> setBody(out, payload);
> outExchange.setInMessage(out);
> getDeliveryChannel().sendSync(outExchange);
> }
> done(exchange);
> }
>
> I see that this seems to work fine, but I'd like to know if this is
> correct. One thing that bothers me is that i have to do "sendSync"
> but I think i want to just send. When I do that i get the following:
>
> SEVERE: org.servicemix.jbi.nmr.flow.seda.SedaQueue$1@13c652 Gor error
> processing org.servicemix.jbi.messaging.InOnlyImpl@413e5a
> javax.jbi.messaging.MessagingException: illegal call to send
>
> Thanks,
> Jason
>
> On Mar 20, 2006, at 10:37 AM, Jason Vinson wrote:
>
> > Hi,
> >
> > I'm very new to servicemix, but I have a question about what is the
> > best approach to start writing "service engines" to use in a
> > servicemix esb. My first thought is to write a class that extends
> > PojoSupport and implements MessageExchangeListener, but I wanted to
> > find out from the experts if this is the desired implementation.
> >
> > I've also been drawn towards the TransformComponentSupport class,
> > which I suppose could be used to plug in a service as well, but the
> > name implies that it's to be used for transformation, not service
> > execution. Could I get some info regarding this, or at least
> > pointers to a clear tutorial on this concept?
> >
> > Thanks so much,
> > Jason
>
>
>
Re: Best Way to Start out with ServiceMix
Posted by Jason Vinson <vi...@charter.net>.
I found a way to do this that i think is correct. The following is
what i came up with (parts borrowed from ScriptComponent):
public void onMessageExchange(MessageExchange exchange)
throws MessagingException {
NormalizedMessage in = exchange.getMessage("in");
Object payload = getBody(in);
// do something with it...
processPayload(payload);
if (isInAndOut(exchange)) {
NormalizedMessage out = exchange.createMessage();
exchange.setMessage(out, "out");
} else {
InOnly outExchange = getExchangeFactory().createInOnlyExchange();
NormalizedMessage out = outExchange.createMessage();
setBody(out, payload);
outExchange.setInMessage(out);
getDeliveryChannel().sendSync(outExchange);
}
done(exchange);
}
I see that this seems to work fine, but I'd like to know if this is
correct. One thing that bothers me is that i have to do "sendSync"
but I think i want to just send. When I do that i get the following:
SEVERE: org.servicemix.jbi.nmr.flow.seda.SedaQueue$1@13c652 Gor error
processing org.servicemix.jbi.messaging.InOnlyImpl@413e5a
javax.jbi.messaging.MessagingException: illegal call to send
Thanks,
Jason
On Mar 20, 2006, at 10:37 AM, Jason Vinson wrote:
> Hi,
>
> I'm very new to servicemix, but I have a question about what is the
> best approach to start writing "service engines" to use in a
> servicemix esb. My first thought is to write a class that extends
> PojoSupport and implements MessageExchangeListener, but I wanted to
> find out from the experts if this is the desired implementation.
>
> I've also been drawn towards the TransformComponentSupport class,
> which I suppose could be used to plug in a service as well, but the
> name implies that it's to be used for transformation, not service
> execution. Could I get some info regarding this, or at least
> pointers to a clear tutorial on this concept?
>
> Thanks so much,
> Jason