Pages

Tuesday, July 3, 2012

Do WebLogic configuration from ANT

With WebLogic WLST you can script the creation of all your Application DataSources or SOA Integration artifacts( like JMS etc). This is necessary if your domain contains many WebLogic artifacts or you have more then one WebLogic environment. If so, you want to script this so you can configure a  new WebLogic domain in minutes and you can repeat this task with always the same result.

I started a new project on Github https://github.com/biemond/soa_tools/tree/master/ant_wls which can do this from ANT, for this I created some WLST ANT macrodefs. These ANT targets can be invoked many times ( great for Continuous Integration ) and if the object already exists it rollbacks the edit action and give a BeanAlreadyExists exception. Great way to keep all your environments in sync.

These ANT scripts can do the following configuration.

  • Create users and roles
  • Reset or create JDBC DataSources 
  • File or JDBC persistence stores
  • JMS servers
  • JMS modules
  •    Sub Deployments
  •    Foreign Servers
  •       Foreign Server Destinations
  •       Foreign Server Connection Factories
  •    Connection Factories
  •    Queues ( Distributed )
  •    Topics ( Distributed )
  •    SAF Remote Contexts
  •    SAF Imported Destinations 
  • SAF agents 

Still to do  is the creation of SAF Imported Destinations.   

An example of an ANT macrodef with the WLST code for the creation of a Queue or a Topic on a WebLogic server or cluster, also supports distributed Queue or Topics plus re-directing to an other Queue.



Snippet of the ANT build.xml with the ANT target which calls this Macrodef and uses the build.properties for all the JMS objects definitions. The foreach is provided by the ANT Contrib library, this is not part of ANT and need to downloaded separately .


Snippet of the build.properties with all the weblogic environments. Just change wls.environment to acc or   some other value.

wls.environment=dev

# dev deployment server weblogic
dev.serverURL=t3://localhost:7001
dev.user=weblogic
dev.password=weblogic1
dev.target=AdminServer

# acceptance deployment server weblogic
acc.serverURL=t3://soaps3:7001
acc.user=weblogic
acc.password=weblogic1
acc.target=soa_server1



# All jms objects entries like Queue, Topic or distributed
queuesOrTopics=error1,queue1

# JMS module name
error1.jmsModule=JMSModule1
# JMS module subdeployment.
error1.subDeployment=JmsServer
error1.jmsName=ErrorQueue      
error1.jmsJNDIName=jms/ErrorQueue
# queue, topic
error1.jmsType=queue
# distributed true ,false
error1.distributed=false
error1.balancingPolicy=xxxxx
# redirect to an error Queue
error1.redirect=false
error1.limit=xxxxx
error1.policy=xxxxx      
error1.errorObject=xxxxx

queue1.jmsModule=JMSModule1
queue1.subDeployment=JmsServer
queue1.jmsName=Queue1      
queue1.jmsJNDIName=jms/Queue1
queue1.jmsType=queue
queue1.distributed=false
queue1.balancingPolicy=xxxxx
queue1.redirect=true
queue1.limit=3
queue1.policy=Redirect
queue1.errorObject=ErrorQueue

And we can run the ANT target when we execute the following command.

ant -f build.xml createCreateJMSQueuesOrTopics


https://github.com/biemond/soa_tools/tree/master/ant_wls

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.