Showing posts with label aerogear. Show all posts
Showing posts with label aerogear. Show all posts

Wednesday, October 21, 2015

Using the Unified Push Server with BPMS

During this past Red Hat Summit I worked on a session with Mobile, Fuse and BPMS.  It was a great pleasure working with Phil SimpsonJavier Perez and  Maggie Hu to build and present the demo.  Below I walk through setting up and using the Push Notification Server.  For information on submitting claims through the mobile application and the adjudicator review you can review Maggie's Blog on Red Hat Mobile Application Platform - Connecting to JBoss BPMSuite REST.

Red Hat Summit 2015 - 
Photo Taken by Wanja Pernath

This article is part of a series we're putting together for the Build an Enterprise Application in 60 Minutes with JBoss Middleware session at the Summit. The original slide decks can be found below from Maggie on Slideshare. Please take a look at the slide decks to get a better idea on the use case we're working with.

Basically, we're allowing people to submit claims quickly from their mobile devices with some basic information when an auto accident happens. The claim will get submitted to the insurance company, an adjudicator will review the claim, set the settlement amount, and complete the claim. Then the policy holder will receive a push notification on their mobile device on the settlement amount.




What is Push Notification and its benefits?

A push notification is a message or alert delivered by a centralized server (on premise or cloud) to a device.   Unlike pull notifications, in which the client must request information from a server, push notifications originate from a server. Typically, the end user must opt-in to receive alerts; opt-in usually takes place during the install process and end users are provided with a way to manage alerts if they change their minds later on.

An important advantage of push notifications in mobile computing is that the technology doesn't require specific applications on a mobile device to be open in order for a message to be received. This allows a smartphone to receive and display social media or text message alerts even when the device's screen is locked and the social media application that is pushing the notification is closed.

The Red Hat Mobile Unified Push Server (Aerogear) can be seen as a broker that distributes push messages to different 3rd party Push Networks. The graphic below gives a little overview:


  1. One PushApplication and at least one mobile platform variant must be created.
  2. The variant credentials that are generated and stored by the UnifiedPush Server must be added to the mobile application source, enabling the application to register with the UnifiedPush Server once it is installed on mobile devices.
  3. Sending a push message can happen in different ways: The AdminUI can be used to send a (test) message to registered devices. However, in a real-world scenario the Push Notification Message request is triggered from a backend application, which sends its requests using the Sender API. Different SDKs for different languages are supported.
  4. The push request is then translated into platform specific details for the required variant Push Network. The Dashboard of the AdminUI gives a status report if a message is sent to the Push Network.
  5. The UnifiedPush Server does not directly deliver the message to the mobile device. This is done by the appropriate variant Push Network. Note: There can be latency in the actual delivery. Most Push Networks, such as APNs or GCM, do not guarantee to deliver messages to mobile devices.
Setting Up the Unified Push Server on Openshift

The Unified Push Server allows developers to send native push messages to Apple’s Push Notification Service (APNS) and Google’s Cloud Messaging (GCM). It features a built-in administration console that makes it easy for developers to create and manage the push related aspects of their applications for any mobile development environment. Includes client SDKs (iOS, Android, & Cordova), and a REST based sender service with an available Java sender library.

In our example we setup the UPS on Openshift instead of on premise and we do this through the Openshift Application Manager.  First we need a Openshift account.  You can sign up for a free account for 3 small gears.


Next we will create an openshift application.


We will use the Unified Push Server 1.0 Cartridge which will also add MySQL to the Application.  We can take the defaults and click Create Application Button.  After creating the application a credentials screen is displayed with URLs and credentials.


Now we can sign onto the console to create applications, variants, etc and monitor messages.  Let's open the dashboard for the Push Server, ie https://jbossunifiedpushtest2-ossmentor.rhcloud.com/ag-push, and login with admin/admin which will bring up the dasboard main screen.


Now we want to add an application to receive the push notifications.  We click on applications and the create application button.  Once created we can look at the variants.  This shows the application ID and Master Secret for the application which we will use in our example.



At this point we can create variants for Android and iOS.   For this first example we will create an application but won't use variants and register devices.  We will just show the notification getting to the push notification server.  Now that the application is created let's do a quick test.

Test sending a message to the UPS

I used the Advanced REST Client in Chrome to test the message.  I setup the project with the URL, the Authorization and Content Type as shown below.  I put in some sample data for the notification.


After clicking on send I get a Job submitted response and can lookup the message in the dashboard.



Now let's move onto how we can make the call from BPMS.

Sending a notification message from BPMS to the UPS



First in our Business Process we add the message in a script task to the Response Body for the REST call.

kcontext.setVariable("requestBody","{\"ttl\":3600,\"message\":{\"alert\":\"Your Payment Amount is:"+kcontext.getVariable("paymentAmount")+"\",\"action-category\":\"some value\",    \"sound\":\"default\",\"badge\":2,\"content-available\":true},\"simple-push\":\"version=123\"}");

Next in our Business Process we added a REST Task to make the call to the UPS to send the claim award message.  A couple of items to note on the Task.  The first is the data assignments.  The username is the Application ID and the password is the Master Secret as seen in the screen shots below.  Also note the URL for the domain REST API for UPS in addition to the Basic Authorization.




Note the App settings in addition to the Android Variant settings for Google Cloud messaging.
Also in the REST Task we setup the Data Input and Output as indicated below.

One additional item that was required is the work definition as displayed below.

import org.drools.core.process.core.datatype.impl.type.StringDataType;
import org.drools.core.process.core.datatype.impl.type.ObjectDataType;
[
  [
    "name" : "Email",
    "parameters" : [
      "From" : new StringDataType(),
      "To" : new StringDataType(),
      "Subject" : new StringDataType(),
      "Body" : new StringDataType()
    ],
    "displayName" : "Email",
    "icon" : "defaultemailicon.gif"
  ],
  [
    "name" : "Log",
    "parameters" : [
      "Message" : new StringDataType()
    ],
    "displayName" : "Log",
    "icon" : "defaultlogicon.gif"
  ],
  [
    "name" : "WebService",
    "parameters" : [
        "Url" : new StringDataType(),
         "Namespace" : new StringDataType(),
         "Interface" : new StringDataType(),
         "Operation" : new StringDataType(),
         "Parameter" : new StringDataType(),
         "Endpoint" : new StringDataType(),
         "Mode" : new StringDataType()
    ],
    "results" : [
        "Result" : new ObjectDataType(),
    ],
    "displayName" : "WS",
    "icon" : "defaultservicenodeicon.png"
  ],
  [
    "name" : "Rest",
    "parameters" : [
        "Url" : new StringDataType(),
        "Method" : new StringDataType(),
        "ConnectTimeout" : new StringDataType(),
        "ReadTimeout" : new StringDataType(),
        "Username" : new StringDataType(),
        "Password" : new StringDataType()
    ],
    "results" : [
        "Result" : new ObjectDataType(),
    ],
    "displayName" : "REST",
    "icon" : "defaultservicenodeicon.png"
  ]
]
That was all that is required to send a push notification from BPMS to the Unified Push server.  You can see the messages in the UPS console.
All variants associated with the Application in UPS will receive the notification.  We will cover the Android application in a follow up article to register the device with Google Cloud Messaging (GCM) and receive the notification. 

References:
http://searchconsumerization.techtarget.com/definition/push-notification
https://aerogear.org/docs/unifiedpush/ups_userguide/index/
https://developers.openshift.com/en/xpaas-unified-push.html

Thursday, October 15, 2015

Webinar: Build your next business application in 60 minutes

IT is at the center of change in application development as new approaches like DevOps emphasize rapid delivery of features and greater participation by end users and “citizen developers.” Middleware technologies such as integration, business rules, business process management (BPM), mobile application platforms, and Platform-as-a-Service (PaaS) are emerging as important tools for DevOps teams, greatly reducing the traditional coding requirements for new business applications.

Join us for this webinar to learn how two middleware technologies—business process management and mobile app development platforms—can work together in the cloud to support development of process-enabled mobile business apps. Through a real-word use case, we will demonstrate:
  • Development and deployment of a mobile business app using Red Hat® Mobile Application Platform.
  • Platform inclusion of captured mobile information into business processes with Red Hat JBoss® BPM Suite.
  • Integration of automated processes with systems of record with Red Hat JBoss Fuse.
    Speakers:
    Phil Simpson, senior principal product marketing manager, Red Hat
    Maggie Hu, middleware specialist solution architect, Red Hat
    Kenny Peeples, JBoss technology evangelist, Red Hat

    Join the live event:
    Time zone converter
    • Thursday, October 22, 2015 | 11 a.m. EDT | 8 a.m. PDT
    Register Now

    Monday, October 27, 2014

    The past week in review for the JBoss Community

    This week is my first time posting for the weekly editorial and excited to join the team. There is a lot to highlight for this weeks editorial. Autumn is now upon us in the Northern Hemisphere which marks the transition from summer to winter. The arrival of night is earlier, temperature is cooling and leaves are turning color as well as falling. I was at the Boston office a couple of weeks ago and the area was beautiful with the change in the color of the leaves in addition to the cool weather. With the transition of warm to cold weather autumn is known as the primary harvest with many harvest festivals celebrated across the globe. Whether you celebrate Labor Thanksgiving Day in Japan, the Dutch Feast of Saint Martin of Tours, American Thanksgiving Feast, Canadian Thanksgiving Feast, German Martinmas, Czech Republic Posviceni/Obzinky, Chinese Harvest Moon Festival, etc., have a great Autumn.

    Now on to our exciting JBoss weekly content

    Job Opening


    Red Hat is the best company in the world to work. I have enjoyed Red Hat since day one and continue to enjoy the work, the people and the open source culture. We have a current job opening for a Software Sustaining Engineer who will help improve the quality of the BRMS and BPM Suite platforms which are the productised versions of the Drools and jBPM open source projects. So if you love Drools and jBPM, and want to help make them even better and even more robust - then this is the job for you The role is remote, so you can be based almost anywhere.


    Events


    We had several events that took place plus some coming up:
    • 300+ kids, 16 speakers (4 from middle/high school), 6 rooms, 24 sessions of 75 mins each = extremely rewarding weekend + inspired kids! Silicon Valley Code Camp Kids (SVCC.kids) is a one-day event that is a new addition to the famous Silicon Valley Code Camp (SVCC) event. The event was held at Foothill College in Los Altos Hills, CA on October 12th.
    • DecisionCAMP 2014 took place at San Jose on October 13-15 which is a free conference in the San Jose area for business rules and decision management practitioners. The conference concentrates on Business Rules and Decision Management. Decision Management is the art or science, depending on your perspective, of automating decisions in your systems.
    • Last week was the Openslava 2014 Conference for emerging technologies and open-source in Bratislava, Slovakia. Videos from the talks will be published soon. Markus Eisele posted a Trip Report which also included a video and presentation on 50 best features of Java EE 7.
    • Coming up in November we have several people from Red Hat involved at Devoxx BE 2014. Devoxx has grown to be one of the most popular Java conferences series in Europe. This year we are excited to announce that JBoss will be presenting a keynote on the future capabilities of PaaS. We have severalspeakers who are speaking on a variety of topics. Visit JBoss Community members at Devoxx University, the Hackergarten, the sessions or have a drink with us at Nox!

    Blog/Articles


    A lot of blogs and articles were posted the last couple of weeks so I listed them here for your reading pleasure:
    1. JBoss Teiid
    2. JBoss BRMS and JBoss BPM Suite
    3. JBoss Fuse
    4. JBoss Wildfly
    5. JBoss Aerogear
    • Markus Eisele provided another episode his developer interview which took place with Matthias Wessendorf. Matthias is working at Red Hat where he is leading the AeroGear project. Previously, he was the PMC Chair of the Apache MyFaces project. Matthias is a regular conference speaker.

    Releases


    The last couple of weeks we had several new project releases. Take all of them for a spin and enjoy!
    • JBoss Tools and Developer Studio for Eclipse Luna! There have been many feature additions and a lot of bug fixing polish going into this main release and these have been documented/described in details atWhat’s New.
    • Immutant 2 (The Deuce) Alpha2 Released! We're as happy as a cat getting vacuumed to announce our second alpha release of The Deuce, Immutant 2.0.0-alpha2. Big, special thanks to all our early adopters who provided invaluable feedback on alpha1 and our incremental releases.
    • Infinispan 7.0.0.CR2 released! As we approach final release, the main themes of this CR were bug fixes and enhancements, many related to Partition Handling.
    • JGroups 3.6.0.Final released! We just released 3.6.0.Final to SourceForge [1] and Nexus. It contains a few new features, but mostly optimizations and a few bug fixes. It is a small release before starting work on the big 4.0.
    • RichFaces 4.5.0.CR2 Release Announcement! We have a second candidate release for RichFaces 4.5 (4.5.0.CR2) available. We’ve fixed a couple of regressions uncovered by both our community and QA team.
    • Teiid 8.9 CR1 Posted! After a small delay Teiid 8.9 CR1 has been posted to the maven repository and the download page.
    • SwitchYard 2.0.0.Alpha3 Now Available! The SwitchYard team has been making steady progress on the 2.0 release and I'm pleased to announce the latest preview of SwitchYard 2.0, Alpha3. We're rapidly approaching beta quality and the only think keeping this release from being called a beta is the lack of support for BPM and rules components on WildFly. Overall, the team has made great progress improving stability, especially on Fuse/Karaf.

    That's all for this week, please join us next week when we will share more news about the JBoss Community.