Thursday, June 21, 2012

ADF development with Eclipse (OEPE)

Finally with Eclipse ( OEPE ) as IDE we can use the ADF Binding framework in our ADF applications development ( works with PS3 and higher ) . Last year I already blogged about the support for ADF Rich Faces and with this release of  OEPE ( it is still a Technical Preview) we can fully develop ADF applications in Eclipse. Off course you don't have the ADF BC wizards of JDeveloper and you need to use EJB, JPA or a web service proxy for retrieving data ( and optionally generate an ADF  DataControl  ). 

In this blogpost I continue my previous blogpost with the new ADF Binding features in Eclipse

First we got a separate Data tab window with all the imported or generated ADF Data Controls, Managed Beans and an overview of the used page variables like row in an ADF Table.

A Page Definition editor with its usage ( very nice ). But it does not contain all the possible iterator configurations options ( missed these two important options: refresh and change event policy ).

The Task Flow editor got some extra options like defining breakpoints.

When we select our Web project, we can generate an new ADF Data Model Component

This will generate an EJB Session bean with a local and remote interface.

This EJB can be invoked from a JSF managed bean or generate a ADF Data Control on the local interface.

The ADF Binding artifacts will be generated in its own adfmsrc folder.

We can also generate an ADF DataControl on our own java class.

If you have ADF DataControls in two or more projects you need to move one of the DataControls.dcx to a unique package. Else ADF can't load the second DataControls.dcx file.

Let's hope we soon get a OEPE version for WebLogic 12c with JSF2 + all the nice Java EE 6 support.

Wednesday, June 13, 2012

WebLogic JMS / AQ bridge with JBoss AS 7

There are different ways to exchange JMS messages between WebLogic and JBoss Application Server 7. In this blogpost I will explain how you can retrieve JMS messages from JBoss ( with the help of a WebLogic Foreign Server ) and how to push messages to JBoss AS ( with the help of a WebLogic JMS Bridge). This even works with AQ.

For JBoss AS 7 I will use the JMS ( HornetQ ) / JBoss configuration which I already explained in this blogpost. On the WebLogic side I will use WebLogic 11gR1 PS5 or version 10.3.6.

Before we start we need to add the jboss / hornetq jars to the lib folder of your domain. Use jboss-client.jar from the bin/client jboss folder and we need to download the lates HornetQ libraries ( hornetq-2.2.14.Final) . Use the hornetq-jms-client.jar from the HornetQ lib folder.

The best way to retrieve JMS messages from JBoss AS 7 is using a WebLogic Foreign Server. In the current version of JBoss 7.1.1 it is not possible to setup bridging in the console or in one of the instances xml's.

Create a Foreign Server in a JMS module and use default targetting or target this to a WebLogic server

JNDI Initial Contect Factory is org.jboss.naming.remote.client.InitialContextFactory
JNDI Connection URL is remote://yourJbossServer:4447
Provide the remote password
In the JNDI properties add the remote username

Provide the Remote JNDI name of the Queue.

Provide the remote JNDI name of the JBoss Connection Factory -> jms/RemoteConnectionFactory

Now you deploy a MDB or a OSB process which listens on the local JNDI CF and Queue.

Second part is setting up a JMS bridge between WebLogic and JBoss. This way local messages in a local JMS or AQ Queue can be pushed to JBoss AS.

First we need to deploy two resource adapters jms-notran-adp and jms-xa-adp these rar files are located at the wlserver_10.3\server\lib. Deploy them as application and target them to the right weblogic servers.

Add a JMS Bridge Destination ( JBoss AS), this configuration is almost the same as the JBoss Foreign Server configuration.
Only choose eis/jms/WLSConnectionFactoryJNDIXA as Adapter JNDI Name.

The JMS Bridge Source ( WebLogic side )

Add a Bridge where we select the Destination and Source. Important, use Atmost-once for Quality of Service. Exactly once won't work.

Enable the started checkbox.

Add some messages to the WebLogic Queue and see if it delivered to JBoss.

Last part is to use Oracle Database AQ as source for this JMS bridge. For all the information, how to setup AQ on WebLogic see this excellent Oracle Documentation.

Create a Foreign Server, target this to a WebLogic server and use oracle.jms.AQjmsInitialContextFactory as JNDI Initial Context Factory also add a JNDI property with the JDBC datasource as value.

Add the AQ Queue name with its local WebLogic JNDI name.

Also define the Connection Factory.

And here the matching JMS bridge source which will work on the AQ Foreign server.

Happy messaging.

Friday, June 8, 2012

Remote JMS with JBoss AS 7.1 / HornetQ JMS

When you want to connect to a Queue or Topic on JBoss Application Server 7.1.1 with a remote jms client you can follow the next steps.

First step is to add messaging configuration to the JBoss configuration xml. In this case I will use the standalone configuration.

Open standalone.xml located at jboss-as-7.1.1.Final\standalone\configuration

Add to the extensions

<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:1.2">
        <extension module=""/>
        <extension module=""/>

Add the HornetQ messaging configuration, make sure it is the first xml entry after profile.

        <subsystem xmlns="urn:jboss:domain:messaging:1.1">

                    <netty-connector name="netty" socket-binding="messaging"/>
                    <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
                        <param key="batch-delay" value="50"/>
                    <in-vm-connector name="in-vm" server-id="0"/>

                    <netty-acceptor name="netty" socket-binding="messaging"/>
                    <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
                        <param key="batch-delay" value="50"/>
                        <param key="direct-deliver" value="false"/>
                    <in-vm-acceptor name="in-vm" server-id="0"/>

                    <broadcast-group name="bg-group1">

                    <discovery-group name="dg-group1">

                    <cluster-connection name="my-cluster">
                        <discovery-group-ref discovery-group-name="dg-group1"/>

                    <security-setting match="#">
                        <permission type="send" roles="guest"/>
                        <permission type="consume" roles="guest"/>
                        <permission type="createNonDurableQueue" roles="guest"/>
                        <permission type="deleteNonDurableQueue" roles="guest"/>

                    <address-setting match="#">

                    <connection-factory name="InVmConnectionFactory">
                            <connector-ref connector-name="in-vm"/>
                            <entry name="java:/ConnectionFactory"/>
                    <connection-factory name="RemoteConnectionFactory">
                            <connector-ref connector-name="netty"/>
                            <entry name="RemoteConnectionFactory"/>
                            <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                    <pooled-connection-factory name="hornetq-ra">
                        <transaction mode="xa"/>
                            <connector-ref connector-name="in-vm"/>
                            <entry name="java:/JmsXA"/>

                    <jms-queue name="testQueue">
                        <entry name="queue/test"/>
                        <entry name="java:jboss/exported/jms/queue/test"/>
        <subsystem xmlns="urn:jboss:domain:logging:1.1">

We will use 

RemoteConnectionFactory as JMS ConnectionFactory with "java:jboss/exported/jms/RemoteConnectionFactory" as JNDI name. Use jms/RemoteConnectionFactory as CF reference in your java client.

queue/test as Queue with as jndi name "java:jboss/exported/jms/queue/test".  Use  jms/queue/test as Queue reference.

For remote it should start with java:jboss/exported/ else these object won't be exposed and then you can't lookup the CF or Queue.

Also for remote we need to create a application user. Go to the bin folder and start
Create a user jms with a password and add this user to the guest role. Guest role has permission for remote and jms. 

Start JBoss with the standalone configuration.

For our java test clients we need to have a jboss and a HornetQ jar file.
First copy jboss-client.jar from the bin/client jboss folder and we need to download the lates HornetQ libraries ( hornetq-2.2.14.Final) . Copy hornetq-jms-client.jar from the HornetQ lib folder.

First the Jms Send Client

Jms Receive Client

In this example I use the same username , password for createQueueConnection
 QueueConnection qcon = qconFactory.createQueueConnection("jms","jboss1");

If you don't do this you will get this error Unable to validate user: null

INFO: JBoss Remoting version 3.2.3.GA
Exception in thread "main" javax.jms.JMSSecurityException: Unable to validate user: null
at org.hornetq.core.protocol.core.impl.ChannelImpl.sendBlocking(
Caused by: HornetQException[errorCode=105 message=Unable to validate user: null]

To solve this you can also disable messaging security
        <subsystem xmlns="urn:jboss:domain:messaging:1.1">

Now you can also use QueueConnection qcon = qconFactory.createQueueConnection();

That's all