Categories

  • An excellent post on delivering real-time updates from .NET to JavaScript via WebSockets by using WebORB for .NET: http://t.co/8ONjyw59
  • We're working on some cool samples demonstrating Sencha component integration with WebORB's websockets and data management. Stay tuned.
  • For all Flexers out there, check out the following blog post, looks like a problem in ArrayCollection serialization: http://t.co/qbZuTEhy
  • none - intentionally blocks websocket handshake responses. Not only they do not support it, they do not allow others either

Archives

Dynamic Messaging Destinations for Flex and other clients

Messaging destinations is the central concept in publish/subscribe messaging supported by WebORB. The feature is available for Flex, AIR, Javascript, native Java/Android, and .NET clients. A program can be in the role of producer or consumer (or both). Producers publish messages into a destination and consumers subscribe to receive published messages. Typically messaging destinations are registered in a configuration file (WEB-INF/flex/messaging-config.xml), however, WebORB also supports destinations created at run-time – thus called dynamic messaging destinations. The dynamic nature of the destinations can add a lot of flexibility to applications relying on publish/subscribe messaging. For instance, one can easily create a short-lived messaging destination for quick message exchange or some private messaging. The example below demonstrates Java code registering a dynamic destination using the WebORB for Java API:

package demo.messaging.destination;
import weborb.ORBConstants;
import weborb.config.FlexMessagingServiceConfig;
import weborb.config.ORBConfig;
import weborb.config.ORBServerConfig;
import weborb.management.messaging.FlexMessagingDestination;
import weborb.messaging.v3.MessagingDestination;
import weborb.messaging.v3.MessagingServiceHandler;
import weborb.v3types.core.DataServices;

import java.util.Hashtable;

public class DestinationFactory
{
  public String createMessagingDestination( String name ) throws Exception
  {
    // create destination object. This is as basic as it gets, constructor with the destination name
    MessagingDestination destination = new MessagingDestination( name );

    // setup the most basic properties - the name of the class handling
    // subscriptions and publications and a class where the messages are stored
    // until they are retrieved by the consumers.
    Hashtable properties = new Hashtable();
    properties.put( ORBConstants.MESSAGE_STORAGE_POLICY, "weborb.messaging.v3.MemoryStoragePolicy" );
    properties.put( ORBConstants.MESSAGE_SERVICE_HANDLER, "weborb.messaging.v3.MessagingServiceHandler" );

    // register properties
    destination.setProperties( properties );

    // initialize handler from the properties
    destination.setConfigServiceHandler();

    // register the destination
    DataServices dataServices = ORBConfig.getORBConfig().getDataServices();
    dataServices.getDestinationManager().addDestination( name, destination );

    // REGISTERING DESTINATION SO IT IS VISIBLE IN THE MANAGEMENT CONSOLE
    // The following two lines are needed if you would like the destination
    // to appear in the management console, therefore the code below is optional

    // set the channel name, so the console knows how to connect to the destination
    // in the "Test Drive" mode.
    destination.setChannelName( "my-polling-amf" );
    FlexMessagingServiceConfig serviceConfig = ORBServerConfig.getFlexMessagingServiceConfig();
    serviceConfig.addFlexMessagingDestination( FlexMessagingDestination.getDestinationScope( destination ) );
    return name;
  }
}

To further demonstrate how dynamic destinations can be used with the Flex client, see the following Flex application code. The application’s workflow consists of the following steps:

  1. User enters a name for a dynamic destination to create and pressed the Create Destination button.
  2. Flex client invokes the createMessagingDestination Java method shown above.
  3. When the remote method invocation returns a result, the Flex client constructs a Producer and a Consumer objects. The consumer is subscribed to the newly created destination.
  4. When the user enters text and clicks the Send Message button, the Flex client uses the Producer object to publish the message into the destination.
  5. The consumer object receives the message from the destination and displays it in the text area.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx"
			   width="100%" height="100%" creationComplete="init()">
  <s:layout>
    <s:FormLayout/>
  </s:layout>
  <s:states>
    <s:State name="InitialState"/>
    <s:State name="DestinationCreated"/>
  </s:states>
  <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
  </fx:Declarations>
  <fx:Script>
    <![CDATA[
  import mx.controls.Alert;
  import mx.messaging.ChannelSet;
  import mx.messaging.Consumer;
  import mx.messaging.Producer;
  import mx.messaging.channels.AMFChannel;
  import mx.messaging.events.MessageEvent;
  import mx.messaging.messages.AsyncMessage;
  import mx.rpc.events.FaultEvent;
  import mx.rpc.events.ResultEvent;
  import mx.rpc.remoting.RemoteObject;
  import weborb.messaging.WeborbMessagingChannel;

  private var remoteService:RemoteObject;
  private var consumer:Consumer;
  private var producer:Producer;

  public function init():void
  {
    remoteService = new RemoteObject( "GenericDestination" );
    remoteService.source = "demo.messaging.destination.DestinationFactory";
    remoteService.createMessagingDestination.addEventListener( ResultEvent.RESULT, destinationCreated );
    remoteService.createMessagingDestination.addEventListener( FaultEvent.FAULT, gotError );
  }

  private function destinationCreated( evt:ResultEvent ):void
  {
    currentState = "DestinationCreated";

    consumer = new Consumer();
    consumer.destination = evt.result as String;
    //var channel:AMFChannel = new AMFChannel( "custom-amf-channel", "weborb.wo" );
    var channel:WeborbMessagingChannel = new WeborbMessagingChannel( "custom-rtmp-channel", "rtmp://localhost/root" );
    var channelSet:ChannelSet = new ChannelSet();
    channelSet.addChannel( channel );
    consumer.channelSet = channelSet;
    consumer.addEventListener( MessageEvent.MESSAGE, gotMessage );
    consumer.subscribe();

    producer = new Producer();
    producer.destination = evt.result as String;
    producer.channelSet = channelSet;
  }

  private function gotError( evt:FaultEvent ):void
  {
    Alert.show( "Server reported an error: " + evt.fault.faultDetail );
  }

  private function createDestination():void
  {
    remoteService.createMessagingDestination( destinationName.text );
  }

  private function sendMessage():void
  {
    var asyncMessage:AsyncMessage = new AsyncMessage( messageText.text );
    producer.send( asyncMessage );
  }

  private function gotMessage( evt:MessageEvent ):void
  {
    log.text = evt.message.body.toString() + "\n" + log.text;
  }
]]>
</fx:Script>
  <s:HGroup width="100%" paddingBottom="2" paddingTop="2" verticalAlign="middle">
    <s:Label width="150" text="Destination Name:"/>
    <s:TextInput id="destinationName"/>
    <s:Button label="Create Destination" click="createDestination()"/>
  </s:HGroup>
  <s:HGroup width="100%" paddingBottom="2" paddingTop="2" verticalAlign="middle">
    <s:Label width="150" text="Message:"/>
    <s:TextInput id="messageText"/>
    <s:Button label="Send" click="sendMessage()" enabled="false"
      enabled.DestinationCreated="true"/>
  </s:HGroup>
  <s:HGroup width="100%" height="200">
    <s:TextArea id="log" width="413" height="100%"/>
  </s:HGroup>
</s:Application>

Since the client code references the weborb.messaging.WeborbMessagingChannel class (needed only if the client-server publish/subscribe communication should be done via RTMP), the application must reference weborb.swc in the Flash Build Path of the project. The library is available at:

WebORB for Java – [WEBOBR INSTALL DIR]/webapp/weborbassets/wdm

WebORB for .NET – [WEBOBR INSTALL DIR]/weborbassets/wdm

Complete Flex project with the code shown above can be downloaded from:
http://examples.themidnightcoders.com/blog/dynamicdestinations/DynamicDestinationDemo.zip

Compiled Java code can be downloaded from (the file should be deployed into WEB-INF/lib):
http://examples.themidnightcoders.com/blog/dynamicdestinations/dynamicdestinations.jar

For more information about the Dynamic Destination API, see the corresponding section in the WebORB Documentation.

WebORB v4.3 for Java is Released!

I am very happy to report that we released a new version of WebORB for Java – version 4.3. The theme of the release is ‘Developer Productivity’. As you may already know, WebORB enables integration at four different levels: remoting (RPC), data management, real-time publish/subscribe messaging and video/audio streaming and recording. With this release, we deliver code generators for all of these levels of integration. Below is a brief description of the new features you will find in 4.3:

  • Data management for JavaScript Clients – If you’re familiar with WebORB, more than likely you know about our data management framework. If not, then you can learn about it either from the WebORB Data Management documentation or the Data Management webinar recording. In short, the framework lets you quickly import your database schema into our Data Modeller tool and generate client and server-side code to enable full CRUD with your data from the ActionScript or JavaScript client or the server-side code. The same code generator can also create a demo application which demonstrates the power of the API. The JavaScript client support lets you create a data-driven ORM solution for your database in seconds. In addition to the APIs for CRUD operations, the JavaScript client also supports client-synchronization for the changes done by other clients working with the same dataset.
  • Remoting code generator for Robotlegs - Robotlegs is quickly becoming a popular ActionScript framework. We included a very powerful code generator which can generate all the supporting ActionScript classes for a given Java service (POJO, EJB, Spring bean, Grails service or SOAP web service) . The generated code enables remoting with the service and includes all the supporting classes conforming to the Robotlegs framework. This includes controller, events, mediators and ActionScript value objects. Read more about WebORB and Robotlegs integration.
  • Native Android Java code generator and invocation client - WebORB includes a tiny native Java library supporting remote procedure calls of the WebORB hosted services from native Android Java applications. Additionally, we also added a code generator which can create Java client-side code for any given WebORB service. The generated project also includes a visual invoker to make it easier to see the generated code in action.
  • Windows Phone invocation client (with code generator)- similar to the native Android Java library, we also added a native Windows Phone (Silverlight) client-side library into the WebORB distribution. Using the library Windows Phone applications can easily integrate with WebORB-hosted Java services using either RPC or publish/subscribe APIs. There is also a code generator which can create C# code and a sample Windows Phone project for any deployed Java service.
  • New Swiz code generator – We have completely rewritten the Swiz code generator to support the latest release of the Swiz framework. The generated code includes all the events, pre-wired controller, service invoker and value object types.
  • Code generator for rich media Flex, AIR and Mobile apps – WebORB for Java supports the RTMP protocol and enables video streaming and recording, remote shared objects and server-side data push. In this release we added a code generator which can create a sample Flex, AIR or  mobile application with the code demonstrating all of these features. Optionally, the code can be generated to support RTMP tunneling for any of the selected features. Read more..
  • Code generator for multi-client Publish Subscribe messaging – WebORB provides native libraries and APIs for publish/subscribe messaging for Flex, AIR, JavaScript, native Java and .NET clients. The unifying concept for all of these APIs is the messaging destination. With the new release, it is trivially easy to manage destinations and on top of this, developers can quickly generate native publish/subscribe messaging apps for all the supported client-side types.
  • Publish/Subscribe Messaging Test Drive – When you develop a messaging application, it may be very important to be able to observe message traffic over your destination. It is very easy to do that with the new release. Simply open the management console, Find your destination under the Messaging Server tab and click “Test Drive”. The feature lets you both create subscribers and publish test messages.

As you can see it is a feature packed release. We also fixed quite a few bugs and you can access a full report in the Midnight Coders bug tracking system. We plan to publish follow-on posts with videos and examples demonstrating all the new functionality in the coming days.

Enjoy!

Multi Client Messaging Code Generation

One of the new features we included into WebORB version 4.4 for .NET (and very soon in WebORB for Java) is the support for multi-client publish/subscribe messaging. If you’re not familiar with publish/subscribe, it is a simple, yet very powerful data exchange pattern. A computer program may be in one of the two roles (or in both) : a publisher or a subscriber. Publishers send messages to the server and the server routes the messages to all the subscribers. Subscribers can subscribe with some rules: for instance to receive messages which have a specific header. WebORB provides support for this type of integration for a variety of clients, including Flex, AIR, JavaScript, Java (both standalone and Android), Silverlight, Windows Phone and iOS. Some clients, for instance, Flex and AIR, include APIs in their SDKs enabling client-side support for publish/subscribe. For other client types, we provide libraries with the requiring APIs. Additionally, WebORB simplifies the problem of heterogeneous client integration. That means, clients from different environments can easily exchange messages with each other. For example, Android apps can send and receive message to/from Windows Phone or iOS apps. Message handling is also configurable. Published messages can be routed to (or received from) MSMQ, ActiveMQ or any NMS destination.

To make it easier to get started with publish/subscribe, we included messaging code generators into the latest release of WebORB.  The code generators create complete projects with all the source code demonstrating both message publishing and subscription for Flex, JavaScript, Java, Windows Phone and Silverlight. Please keep in mind that the actual run-time support also extends to AIR, Android and iOS. Future versions of WebORB will include code generators for these environments as well.

The video below demonstrates the code generator and the supported APIs. Enjoy!

Pushing Data from Flex to .NET Using WebORB, Apache NMS and ActiveMQ

Developer Gaurav Pandey recently wrote a technical article that shows how to use WebORB with Apache NMS and Apache ActiveMQ. Here is an excerpt from his article.

“The WebORB for .NET messaging framework has been integrated with Apache NMS and is capable of connecting messaging destinations with NMS destinations. This enables Flex applications to deliver data to and retrieve data from any NMS-compatible messaging provider such as Apache ActiveMQ or Microsoft Messaging Queue (MSMQ) with minimal configuration. WebORB acts as a proxy between the Flex clients and the NMS destination. This article provides an overview of pushing data from a Flex publisher client to a Flex consumer client using an ActiveMQ messaging provider.”

To view the entire article with sample code, please visit http://www.adobe.com/devnet/flex/articles/flex-apache-nms.html