-
1. Re: Access EJB
kcbabo Jan 11, 2012 10:36 AM (in response to cvasilak)Is there a reason why this needs to be an EJB? The bean() call you're making now will create the bean instance in Camel vs. calling an existing bean reference. If you wanted to handle with a CDI bean within the application, you can do that and refer to it by name within the route.
One other comment, you can use the declarative transformation support in SwitchYard to handle the JSON unmarshalling instead of declaring that explicitly in your route. It will certainly work as you have it here, so I'm just pointing it out as an alternative (preferred in my mind) option. If you're interested in going that direction, here's an example of what that looks like:
https://github.com/jboss-switchyard/quickstarts/tree/master/transform-json
~ keith
-
2. Re: Access EJB
kcbabo Jan 11, 2012 11:13 AM (in response to kcbabo)BTW, here's an example of a route which references a bean by name:
And here's the bean definition:
-
3. Re: Access EJB
cvasilak Jan 12, 2012 5:27 AM (in response to kcbabo)Hi Keith
adding "bean:Routing?method=addRouteFromRegistrationCommandMsg" worked flawlessly, it uses the EJB Component not a new bean instance.
Basically what I am trying to accomplish is this. I have many distributed clients that submit registration messages through JMS to a main server. I use an EJB there first for shared singleton state (basically the hashmap) between invocations and second for the concurrency reasons. Probably later use a persistent context entiymanager to store the state in a db instance and need transactions... Or probably I missing the big picture here ..
I tried adding the transform.json tags and removing the unmarsal code from the route but I got an exception from camel that it couldn't find the type converter.
Regards
-
4. Re: Access EJB
kcbabo Jan 12, 2012 9:57 AM (in response to cvasilak)Hmm ... that's interesting about the type converter error. The JSON transformer route should definitely work, so if you want to pursue it further, just attach an application that I can use to reproduce the problem and we'll fix it up.
-
5. Re: Access EJB
cvasilak Jan 13, 2012 3:12 AM (in response to kcbabo)Hi Keith
you can find the app to test on github
https://github.com/cvasilak/transform.json
on the parent folder just do
mvn clean install -Dmaven.test.skip=true
Then copy the resulting jars to the jboss7 deployments directory. First the model and then the service
cp svc-rrd-model/target/svc-rrd-model-1.0-SNAPSHOT.jar /jboss-as-7.1.0.CR1b/standalone/deployments/
cp svc-rrd-service/target/svc-rrd-service-1.0-SNAPSHOT.jar jboss-as-7.1.0.CR1b/standalone/deployments/
Afther they are deployed:
cd svc-rrd-service
mvn test
This will send a JMS message to the server containing the JSON payload. At the server console you will get an exception
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: java.lang.String to the required type: gr.forthnet.nms.svcrrd.service.messages.RegistrationCommandMessage ....
Let me know if you need more information
Regads,
Christos