Pages

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  java.naming.security.principal=xxxxx


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 org.jboss.as.messaging to the extensions

<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:1.2">
    <extensions>
        <extension module="org.jboss.as.messaging"/>
        <extension module="org.jboss.as.clustering.infinispan"/>


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


    <profile>
        <subsystem xmlns="urn:jboss:domain:messaging:1.1">
            <hornetq-server>
                <persistence-enabled>true</persistence-enabled>
                <journal-file-size>102400</journal-file-size>
                <journal-min-files>2</journal-min-files>

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

                <acceptors>
                    <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"/>
                    </netty-acceptor>
                    <in-vm-acceptor name="in-vm" server-id="0"/>
                </acceptors>

                <broadcast-groups>
                    <broadcast-group name="bg-group1">
                        <group-address>231.7.7.7</group-address>
                        <group-port>9876</group-port>
                        <broadcast-period>5000</broadcast-period>
                        <connector-ref>
                            netty
                        </connector-ref>
                    </broadcast-group>
                </broadcast-groups>

                <discovery-groups>
                    <discovery-group name="dg-group1">
                        <group-address>231.7.7.7</group-address>
                        <group-port>9876</group-port>
                        <refresh-timeout>10000</refresh-timeout>
                    </discovery-group>
                </discovery-groups>

                <cluster-connections>
                    <cluster-connection name="my-cluster">
                        <address>jms</address>
                        <connector-ref>netty</connector-ref>
                        <discovery-group-ref discovery-group-name="dg-group1"/>
                    </cluster-connection>
                </cluster-connections>

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

                <address-settings>
                    <address-setting match="#">
                        <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                        <expiry-address>jms.queue.ExpiryQueue</expiry-address>
                        <redelivery-delay>0</redelivery-delay>
                        <max-size-bytes>10485760</max-size-bytes>
                        <address-full-policy>BLOCK</address-full-policy>
                        <message-counter-history-day-limit>10</message-counter-history-day-limit>
                        <redistribution-delay>1000</redistribution-delay>
                    </address-setting>
                </address-settings>

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

                <jms-destinations>
                    <jms-queue name="testQueue">
                        <entry name="queue/test"/>
                        <entry name="java:jboss/exported/jms/queue/test"/>
                    </jms-queue>
                </jms-destinations>
            </hornetq-server>
        </subsystem>
        <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 add-user.sh
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(ChannelImpl.java:312)
Caused by: HornetQException[errorCode=105 message=Unable to validate user: null]

To solve this you can also disable messaging security
    <profile>
        <subsystem xmlns="urn:jboss:domain:messaging:1.1">
            <hornetq-server>
                <persistence-enabled>true</persistence-enabled>
                <journal-file-size>102400</journal-file-size>
                <journal-min-files>2</journal-min-files>
                <security-enabled>false</security-enabled> 

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

That's all