Monday, October 10, 2011

Introducing the service repository

(If you want to help out and contribute to jBPM, read this blog all the way to the end, as we're looking for community assistance here!)

Using jBPM5, you can introduce your own domain-specific services in your processes. By defining your own services, they show up as custom service tasks in the graphical process editor. For example, if you would like to send tweets inside your business processes, a special twitter service task can be defined, as shown in the following screenshot.


Configuring domain-specific services has become even easier now, as we now allow you to import services like this from a service repository. You can just browse such a service repository and import the services you would like to use inside your processes. These will then automatically be added to your palette. You can also import a default handler that will be used to execute the service (although you're always free to override the defaults, for example for testing).

The import wizard is created as part of the latest version of the jBPM Eclipse plugin (and will be part of the next release, or you can already try it out by installing the latest plugin from the latest update site). It supports both repositories that are on your file system, or URL-based.

Click on the image below to see a screencast where we import the twitter service in a new jBPM project and create a simple process with it that sends an actual tweet.


[Note that you need the necessary twitter keys and secrets to be able to programatically send tweets to your twitter account. How to create these is explained here, but once you have these, you can just drop them in your project using a simple configuration file.]

We're building a service repository that contains predefined services that people can use out-of-the-box if they want to: http://people.redhat.com/kverlaen/repository. Currently it only contains a few services but we will migrate all existing services there over time.

And this is where we are looking for contributions! There are tons of interesting services and excellent projects that we would like to integrate with. We would like to offer out-of-the-box integration with a lot of those, by defining them as domain-specific services and adding them to the service repository, so people can import them in their processes. So if you would like to contribute integration with a service like that (e.g. facebook, google maps, etc.), or even your own project, let us know!

13 comments:

  1. Can we import the services in Web designer 2.1?

    ReplyDelete
  2. Yes, there is a new section in the docs about that:
    https://hudson.jboss.org/hudson/job/jBPM/lastSuccessfulBuild/artifact/jbpm-distribution/target/jbpm-5.3.0-SNAPSHOT-docs-build/jbpm-docs/html/ch.designer.html#d0e4453

    ReplyDelete
  3. Thanks Kris. As of now it connects default to JBPM service repositry through web Designer 2.1 . Is there any way we can connect to our own repositry through Web Designer (similar to Eclipse by specifying the URL)?

    Thanks

    ReplyDelete
  4. I started the web designer by invoking i this way http://localhost:8080/designer/editor?profile=jbpm&uuid=123456 and now I want to store the design, I have not found a way, different that connecting to a repository. Well I think if the one shown in your blog does not work, I am OK, I am playing with, so no big deal, at this time, what can be done? Is there a way to save the diagram I just build into a file?

    ReplyDelete
  5. The url you are using is more a embeddable, readonly version of the editor. You can however also embed an editable editor, take a look at these docs:
    Designer docs: http://docs.jboss.org/jbpm/v5.3/userguide/ch.designer.html#d0e4501
    Guvnor docs: http://docs.jboss.org/drools/release/5.4.0.CR1/drools-guvnor-docs/html/ch10.html

    At this point, we're delegating all persistence to Guvnor (so you can't currently configure Guvnor to just save a file to file system instead), but we're working on a pluggble implementation with a virtual file system.

    As a work around, you could also export the process after creating it in the designer as BPMN2 xml (see action button on the bottom) and safe that locallly.

    ReplyDelete
  6. Kris, how do you use your "REST" custom task in a process? I have some REST services that I need to integrate into the BPMN workflow that provides some data that is necessary. I couldn't find any README' or docs

    ReplyDelete
  7. The Rest.wid looks like it's the victim of a copy/paste error. The Parameters don't match those in org.jbpm.process.workitem.rest.RestGeoCodeApiCallWorkItemHandler and org.jbpm.process.workitem.rest.RestWorkItemHandler doesn't seem to be present in the jBPM 5.4.0 source.

    ReplyDelete
  8. The source code for the package org.jbpm.process.workitem.twitter is not available in the jbpm-twitter.jar file nor anywhere else.

    ReplyDelete
  9. Jose,

    Sorry, will make sure it's added. But here you go ...

    /**
    * Copyright 2010 JBoss Inc
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */

    package org.jbpm.process.workitem.twitter;

    import java.util.Properties;

    import org.kie.api.runtime.process.WorkItem;
    import org.kie.api.runtime.process.WorkItemHandler;
    import org.kie.api.runtime.process.WorkItemManager;

    import twitter4j.Twitter;
    import twitter4j.TwitterFactory;
    import twitter4j.conf.ConfigurationBuilder;

    public class TwitterWorkItemHandler implements WorkItemHandler {

    private Twitter twitter;

    public void setCredentials(String consumerKey, String consumerSecret, String accessKey, String accessSecret) {
    ConfigurationBuilder configBuilder = new ConfigurationBuilder();
    configBuilder
    .setDebugEnabled(true)
    .setOAuthConsumerKey(consumerKey)
    .setOAuthConsumerSecret(consumerSecret)
    .setOAuthAccessToken(accessKey)
    .setOAuthAccessTokenSecret(accessSecret);
    twitter = new TwitterFactory(configBuilder.build()).getInstance();
    }

    public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
    try {
    if (twitter == null) {
    initTwitter();
    }
    String message = (String)workItem.getParameter("Message");
    if (message != null && message.trim().length() > 0) {
    twitter.updateStatus(message);
    }
    }
    catch(Throwable t) {
    t.printStackTrace();
    manager.abortWorkItem(workItem.getId());
    }
    manager.completeWorkItem(workItem.getId(), null);
    }

    private void initTwitter() throws Exception {
    Properties p = new Properties();
    p.load(TwitterWorkItemHandler.class.getResourceAsStream("/twitter.properties"));
    setCredentials(
    p.getProperty("twitter.consumerKey"),
    p.getProperty("twitter.consumerSecret"),
    p.getProperty("twitter.accessKey"),
    p.getProperty("twitter.accessSecret"));
    }

    public void abortWorkItem(WorkItem workitem, WorkItemManager workitemmanager) {
    }
    }

    ReplyDelete
  10. I'm trying to immport the services by giving the url "http://people.redhat.com/kverlaen/repository"...But looks like its not working.

    Is there any alternative url which I can use?

    ReplyDelete
    Replies
    1. If you're using jBPM6, try using http://docs.jboss.org/jbpm/v6.0.Beta5/repository/

      If not, do you have any error messages in the server log?

      Delete
  11. hi kris ,

    I am getting this error ,can you please guide me what will be the root cause of this error .


    410:
    Relevant discussions can be on the Internet at:
    http://www.google.co.jp/search?q=b2b52c28 or
    http://www.google.co.jp/search?q=1bc21355

    ReplyDelete
  12. Tried Beta, still not wroking..

    ReplyDelete