Invoking a mule non-webservice flow from Activiti - java

I have a JMS mule flow, which will read messages from a queue and process them. I would like to invoke this flow from a process in Activiti. I am using a remote mule instance. From what I understand, to invoke a mule flow in a remote mule instance, I have to use web service. How can I use web service in this case?
I am using the community edition of mule.
Thanks

Assuming you know the Web Service URL for your remote Mule instance, you would need to do one of two things:
Create a serviceDelegate class that calls the Web Service endpoint and call this from Activiti
Use the Camel module with Activiti to handle the call to Mule
Personally I am a fan of using Camel for this sort of thing since the hard work has already been done for you and it is a relatively simple matter to create a camel route and call it from an Activiti service task (there are even BPMN extension attributes built into the latest versions of Activiti that make this even easier).
Other things to consider.
Is this a fire and forget (i.e. one way) call or are you expecting a response? If you are expecting a response, will it be synchronous or asynchronous? All these factors will impact how you model the BPMN flow to properly integrate the Mule flow.

Related

How to create an async web service using jax-ws and OSB12c

I need to create an async web service using jax-ws and I need configure it in a Oracle Service Bus 12c.
will you have some tutorials that explain step by step how to achieve it?
What are the best practices?
If you need to use Oracle Service Bus as an intermediate layer for an asynchronous backend service, you need to create two synchronous proxy services:
First for sending the request to the service and providing the synchronous reponse back to consumer.
Second for sending the asynchronous response to the original consumer.
Service Bus does not support asynchronous (long-running) services. The drawback of this solution is that these two services are completely separate.
I would prefer using BPEL for this scenario (which is also part of SOA Suite), if possible. You can create an asynchronous BPEL process which will cover the whole asynchronous communication by a single SOA composite. You can match the request and asynchronous response and easily indicate which requests got their responses. You can also utilize WS-Addressing.

Existing spring application extension by adding camel features

I have my web application written in Spring MVC. It is quite simple app for registering some activities and generating reports after some time. Now I have it done fully in Spring. The only entry point is HTTP webapp request. I'd like to add other entry points to allow user to trigger application via JMS queue, FTP files and SOAP-based web service.
I know I can do this all using Spring own features somehow, but I wonder if it is desirable to involve Apache Camel into all that stuff?
I think about leaving web application as it is (communicating directly with services), only add some Camel magic to spring context and expose several endpoints from Camel and then after messages processing and transformations call existing services.
I think about using Camel to be able to use some asynchronous processing and threads/scalability features. Is it the right way to go?
I will recommend you to use Apache Camel. I have used it for a similar purpose. The solution is an appropriate one from a 'Separation of Concerns' point. Camel implement Enterprise Integration Patters and is a better solution for integrating various protocols and interfaces. Your application should deal with functionality only and as designed should just expose a servlet to get requests and process it.
Handling of interfaces and protocols are well structured in Camel and its easy to maintain and configure in the long run.

Notification Mechanism Using Spring

I have currently two wars files in which one war has to send notification to other war file using spring.Both of the wars are implemented using spring and web service.
My requirement is first war has to send notifications to other war file.
Could you please provide some pointers to implement the same using spring ?
I do not know exactly your requirements but I'd suggest you to use RestFull web service for this notification. Spring has a perfect support of this kind of services.
Internally the first application will send HTTP POST (or GET) request like http://thehost/webapp2/mynotification
Other way is to communicate using JMS. This way is good if you have to make the communication asynchronous. Spring supports JMS using JMS templates.
You can use:
JMS
a webservice (or spring http invoker) in the target app and invoke it from the notifier
You can use RMI to export your beans and make them visible from other modules, better than other alternatives in this case because:
JMS is asynchronous and needs a middleware.
Webservice are less efficient (since it is mostly conceived to communicate heterogeneous platforms).
Take a look here on how to do it:
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html#remoting-rmi
But I would first of all review the architecture you are using, in case you can refactor it for a better integration of business logic.

How to : Async Callbacks using SOAP/REST Web Services with Java

We have a Java API that needs to be supplemented/fronted with a SOAP/REST Web service Layer.
What does it take to implement Async Calls across process/server boundaries using
a) SOAP Webservices
b) RESTful webservices
Some of the methods might need multiple calls to respond to the request.
We will be using Java/J2ee to implement the SOAP/restful service using a library like CXF or Axis or Jax-RS/WS.
Any examples ? Gotchas ?
Thank you,
The Async Http Client is an open source library that was specifically designed for this type of problem. It utilizes futures and wraps up a lot of the detail and hassle out of making async calls.
The author has a very good getting started guide and there is an active discussion group. The author is a very talented developer and the project is under continuous development.
From the documentation:
The library uses Java non blocking I/O
for supporting asynchronous
operations. The default asynchronous
provider is build on top of Netty
(http://www.jboss.org/netty), the Java
NIO Client Server Socket Framework
from JBoss, but the library exposes a
configurable provider SPI which allows
to easily plug in other frameworks.
Your question is not clear. I am interpreting your question as you want your serverside code to call a remote REST web services in an Async manner. If so then your best bet is to use the Futures feature of java.util.concurrent it will do exactly what you want. If my interpretation of the question is wrong then please update your question with exactly where the async operations need to happen.
Akka http://akka.io/
Great framework, great performance - Here are their claims:
"""
Simpler Concurrency
Write simpler correct concurrent applications using Actors, STM & Transactors.
Event-driven Architecture
The perfect platform for asynchronous event-driven architectures. Never block.
True Scalability
Scale out on multi-core or multiple nodes using asynchronous message passing.
Fault-tolerance
Embrace failure. Write applications that self-heal using Erlang-style Actor supervisor hierarchies.
Transparent Remoting
Remote Actors gives you a high-performance transparent distributed programming model.
Scala & Java API
Scala and Java API as well as Spring and Guice integration. Deploy in your application server or run stand-alone.
"""
#Vivek
GET is async and other HTTP methods
are not.
This isn't true. Please go ahead and read about AJAX :-)
For REST web services (apart from GET) everything else (POST/PUT..) is Async, it returns you the HTTP status code of the opeeration.
If you want to make GET also Async then you will have to use Threads, We did it once in Spring framework using #Async annotation (which internally spawns a thread).
From get return the callback URL as the response and use threads to process the request asynchronously.
Apart from that, For both SOAP / REST once you get the request you can publish it on a JMS queue to make the service Async.
One of the best ways to implement asynch ops is to use callbacks. For REST APIs, design of APIs and Rest client should support this. For instance , client class should pass itself or it's inner class as listner. Rest API on server side should maintain request id and call back listener in map . Once processing is done , it can call method on listener based on request id from map.
Real question: why do you want to call it Async? Having looked at solutions for parallel processing on the Java EE side, it's not recommended that you spawn child threads within a container on your own.
In your case, it looks like the following:
1. you're looking to create a wrapper contract in WSDL (REST or SOAP or both) and if you clients are not just browsers (AJAX)(i mean you'd have adopters from the server-side), then, for JAX-WS -> you could create a #CallBack end-ponint (http://docs.oracle.com/cd/E15051_01/wls/docs103/webserv_adv/callback.html)
or
if it's REST end-point that requires being called from an adopter (server-side), use jAX_RS 2.0 feature
Note: Above assumes it's point to point but in an Async way
Here are a few options:
if you're looking to call REST Or SOAP or some other function asynchronously, you can use workManager API (JSR )
or
use JMS and use a request-reply model if you need it (short running) and calling multiple end-points in parallel
use WS-BPEL (only WSDL end-points) - this is a OASIS standard as well
use SCA (any component with any technology) that can contain assemblies of WS-BPEL component (stateless or stateful) running in BPEL engine like Apache ODE or IBM process server and other components and collaborates. This is a standard

Example of using Mule ESB to route web service calls

I'm looking for an example of how to set up a very simple Mule configuration to route a SOAP web service call from a client to a service provider. Initially, there will just be one provider, and then I will want to add multiple service providers and a round-robin routing strategy in Mule.
Most of the examples on the Mule site have the service provider running within the Mule container. I want mine to be completely external.
If you don't need to decompose message arguments use HTTP pass-through, which is more light-weight and a lot simpler. For the round-robin implementation you could use a filter router with a groovy-based filter expression.
See here:
Create pass through with Mule ESB 2.2.1
http://www.mulesoft.org/documentation/display/MULE2USER/Outbound+Routers#OutboundRouters-Filters

Categories

Resources