Friday, July 31, 2009

EclipseLink JPA

The Eclipse Persistence Services Project (EclipseLink) delivers a comprehensive open-source Java persistence solution.
http://www.eclipse.org/eclipselink/

Developing Applications using EclipseLink JPA
http://wiki.eclipse.org/Category:JPA

Introduction to Java Persistence API (ELUG)
http://wiki.eclipse.org/Introduction_to_Java_Persistence_API_%28ELUG%29

Configuring EclipseLink in Eclipse Galileo


How to use Application Scoped Data Sources in WebLogic with EclipseLink JPA

http://wiki.eclipse.org/EclipseLink/Examples/JPA/WLS_AppScoped_DataSource


persistence.xml using JTA
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="testJPA" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:/app/jdbc/SimpleAppScopedDS</jta-data-source>

<class>testEAR.Author</class>
<class>testEAR.Book</class>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="javax.persistence.jtaDataSource" value="java:/app/jdbc/SimpleAppScopedDS" />
</properties>
</persistence-unit>
</persistence>



[EL Finest]: 2009-07-31 14:42:43.602--UnitOfWork(4744686)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Execute query ReadObjectQuery(referenceClass=Author sql="SELECT AUTHOR_ID, LAST_NAME, EMAIL, FIRST_NAME FROM AUTHOR WHERE (AUTHOR_ID = ?)")
[EL Fine]: 2009-07-31 14:42:43.602--ServerSession(18462140)--Connection(17112484)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--SELECT AUTHOR_ID, LAST_NAME, EMAIL, FIRST_NAME FROM AUTHOR WHERE (AUTHOR_ID = ?)
bind => [1]
[EL Finest]: 2009-07-31 14:42:43.68--ServerSession(18462140)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Execute query ReadAllQuery(name="books" referenceClass=Book sql="SELECT BOOK_ID, TITLE, PUBLISH_DATE, AUTHOR_ID FROM BOOK WHERE (AUTHOR_ID = ?)")
[EL Fine]: 2009-07-31 14:42:43.68--ServerSession(18462140)--Connection(12687286)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--SELECT BOOK_ID, TITLE, PUBLISH_DATE, AUTHOR_ID FROM BOOK WHERE (AUTHOR_ID = ?)
bind => [1]

Convert existing entity EJB to Entity Bean to EJB 3.0

Learn how to convert an EJB 2.0 entity bean to an EJB 3.0 entity bean, step by step.
http://www.oracle.com/technology/pub/articles/vohra_ejb.html?rssid=rss_otn_articles


Understanding Enterprise JavaBeans 3.0
http://edocs.bea.com/wls/docs103/ejb30/understanding.html
Because the EJB 3.0 programming model is so simple, BEA no longer supports using the EJBGen tags and code-generating tool on EJB 3.0 beans.

Thursday, July 30, 2009

Creating JPA project in Eclipse

Introduction to Oracle Enterprise Pack for Eclipse 11g JPA Workbench


http://www.oracle.com/technetwork/articles/cioroianu-eclipse-jpa-084626.html


Dali JPA Tools
An Eclipse Web Tools Platform Sub-Project
http://eclipse.org/webtools/dali/main.php

Generate custom entities



Custom individual entity




Generated entity class

@Entity()
public class Book implements Serializable {
private static final long serialVersionUID = 1L;

@Id()
@SequenceGenerator(name="BOOK_BOOKID_GENERATOR", sequenceName="BOOK_SEQ")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BOOK_BOOKID_GENERATOR")
@Column(name="BOOK_ID")
private long bookId;

private String title;

@Temporal( TemporalType.DATE)
@Column(name="PUBLISH_DATE")
private java.util.Date publishDate;

//bi-directional many-to-one association to Author
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="AUTHOR_ID", referencedColumnName="AUTHOR_ID")
private Author author;

public Book() {
}
public long getBookId() {
return this.bookId;
}

public void setBookId(long bookId) {
this.bookId = bookId;
}

public String getTitle() {
return this.title;
}

public void setTitle(String title) {
this.title = title;
}

public java.util.Date getPublishDate() {
return this.publishDate;
}

public void setPublishDate(java.util.Date publishDate) {
this.publishDate = publishDate;
}

public Author getAuthor() {
return this.author;
}

public void setAuthor(Author author) {
this.author = author;
}

}


@Entity()
public class Author implements Serializable {
private static final long serialVersionUID = 1L;

@Id()
@SequenceGenerator(name="AUTHOR_AUTHORID_GENERATOR", sequenceName="BOOK_SEQ")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="AUTHOR_AUTHORID_GENERATOR")
@Column(name="AUTHOR_ID")
private long authorId;

@Column(name="FIRST_NAME")
private String firstName;

@Column(name="LAST_NAME")
private String lastName;

private String email;

//bi-directional many-to-one association to Book
@OneToMany(mappedBy="author", fetch=FetchType.EAGER)
private java.util.Set<Book> books;

public Author() {
}
public long getAuthorId() {
return this.authorId;
}

public void setAuthorId(long authorId) {
this.authorId = authorId;
}

public String getFirstName() {
return this.firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return this.lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getEmail() {
return this.email;
}

public void setEmail(String email) {
this.email = email;
}

public java.util.Set<Book> getBooks() {
return this.books;
}

public void setBooks(java.util.Set<Book> books) {
this.books = books;
}

}


JPA Field detail



Add JPA project to EJB project


Add finder call to Session Bean

    @PersistenceContext
private javax.persistence.EntityManager em;

@Override
public Author findAuthor(long authorId) {
return em.find(Author.class, authorId);
}


Add session bean call to servlet
 @EJB
TestSessionBeanRemote remoteBusinessIntf;

Author author = remoteBusinessIntf.findAuthor(Long.parseLong(name));

response.getWriter().write(author.getLastName());

Creating new Java project in Eclipse

Organizing source code in Eclipse project

http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jdt.doc.user/gettingStarted/qs-OrganizingSources.htm


Java EE applications
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jst.j2ee.doc.user/topics/ph-j2eeapp.html

Monday, July 27, 2009

Dependency Injection (DI) and JNDI

EJB3 in action http://www.manning.com/panda/
Chapter 2.1.2 - Introducing dependency injection In a sense, injection is lookup reversed. As you can see, in the manual JNDI lookup model, the bean explicitly retrieves the resources and components it needs. As a result, component and resource names are hard-coded in the bean. With DI, on the other hand, the container reads target bean configuration, figures out what beans and resources the target bean needs, and injects them into the bean at runtime.

Inversion of Control Containers and the Dependency Injection pattern
http://www.martinfowler.com/articles/injection.html

Sunday, July 26, 2009

EJB3 Interceptor class example on Weblogic server

Annotations Used to Configure Interceptors
http://edocs.bea.com/wls/docs103/ejb30/annotations.html#wp1428539


Programming the Annotated EJB 3.0 Class
http:
//edocs.bea.com/wls/docs103/ejb30/program.html#wp1207312


Oracle Weblogic example
@Stateful
@TransactionAttribute(REQUIRES_NEW)
@Remote({sessionbean.Account.class})
@Interceptors({sessionbean.AuditInterceptor.class})
public class AccountBean
implements Account
{

private int balance = 0;

public void deposit(int amount) {
balance += amount;
System.out.println("deposited: "+amount+" balance: "+balance);
}

public void withdraw(int amount) {
balance -= amount;
System.out.println("withdrew: "+amount+" balance: "+balance);
}

public int getBalance(){
int bogus;
return balance + 1;
}

@ExcludeClassInterceptors
public void sayHelloFromAccountBean() {

}


@PreDestroy
public void preDestroy() {
System.out.println("Invoking method: preDestroy()");
}

}


Interceptor class
package sessionbean;



import javax.interceptor.AroundInvoke;

import javax.interceptor.InvocationContext;



import javax.ejb.PostActivate;

import javax.ejb.PrePassivate;



/**

* Interceptor class. The interceptor method is annotated with the

* @AroundInvoke annotation.

*/



public class AuditInterceptor {



public AuditInterceptor() {}



@AroundInvoke

public Object audit(InvocationContext ic) throws Exception {

System.out.println("Invoking method: "+ic.getMethod());

return ic.proceed();

}



@PostActivate

public void postActivate(InvocationContext ic) {

System.out.println("Invoking method: "+ic.getMethod());

}



@PrePassivate

public void prePassivate(InvocationContext ic) {

System.out.println("Invoking method: "+ic.getMethod());

}



}




Inject EJB into servlet
@EJB
Account remoteAccount;




Invoking method: public java.lang.Object sessionbean.AccountBean_2lqacg_Impl.beaInvoke(java.lang.Object[],int)
deposited: 200 balance: 800

Saturday, July 25, 2009

Add FastSwap on Weblogic server using Eclipse

Enterprise Application Deployment Descriptor Elements
http://edocs.bea.com/wls/docs103/programming/app_xml.html

Using FastSwap Deployment to Minimize Redeployment
http://edocs.bea.com/wls/docs103/deployment/deployunits.html#FastSwap

Oracle Enterprise pack detailed tutorial
http://www.oracle.com/technology/products/enterprise-pack-for-eclipse/demos.html

Setting FastSwap in Eclipse


weblogic-application.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-application" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_5.xsd http://www.bea.com/ns/weblogic/weblogic-application http://www.bea.com/ns/weblogic/weblogic-application/1.0/weblogic-application.xsd">
<!-- server-version: 10.3.0 -->
<wls:application-param>
<wls:param-name>webapp.encoding.default</wls:param-name>
<wls:param-value>UTF-8</wls:param-value>
</wls:application-param>
<wls:fast-swap>
<wls:enabled>true</wls:enabled>
</wls:fast-swap>

</wls:weblogic-application>

Create Application Lifecycle Listener using Eclipse

http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.wst.webtools.doc.user/topics/cwebartifact.html

Create listener using wizard



Select listener type



package testEAR;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
* Application Lifecycle Listener implementation class TestApplicationLifecycleListener
*
*/
public class TestApplicationLifecycleListener implements ServletContextListener {

/**
* Default constructor.
*/
public TestApplicationLifecycleListener() {
System.out.println("TestApplicationLifecycleListener constructor");
}

/**
* @see ServletContextListener#contextInitialized(ServletContextEvent)
*/
public void contextInitialized(ServletContextEvent arg0) {
System.out.println("TestApplicationLifecycleListener initialize event" + arg0);
}

/**
* @see ServletContextListener#contextDestroyed(ServletContextEvent)
*/
public void contextDestroyed(ServletContextEvent arg0) {
System.out.println("TestApplicationLifecycleListener destroy event" + arg0);
}

}



web.xml descriptor
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>testDynamicWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>TestServlet</display-name>
<servlet-name>TestServlet</servlet-name>
<servlet-class>testEAR.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/sayHello</url-pattern>
</servlet-mapping>
<listener>
<listener-class>testEAR.TestApplicationLifecycleListener</listener-class>
</listener>

</web-app>



TestApplicationLifecycleListener constructor
TestApplicationLifecycleListener initialize eventjavax.servlet.ServletContextEvent[source=weblogic.servlet.internal.WebAppServletContext@194737d
- appName: 'testEAR', name: 'testDynamicWeb', context-path: '/testDynamicWeb', spec-version: '2.5']
...
TestApplicationLifecycleListener destroy eventjavax.servlet.ServletContextEvent[source=weblogic.servlet.internal.WebAppServletContext@194737d
- appName: 'testEAR', name: 'testDynamicWeb', context-path: '/testDynamicWeb', spec-version: '2.5']


Friday, July 24, 2009

Create EJBTimer On Weblogic 10.3 using resource injection

Programming the EJB Timer Service
http://edocs.bea.com/wls/docs103/ejb/implementing.html#wp1191405

EJB 3.0 Metadata Annotations Reference
http://edocs.bea.com/wls/docs103/ejb30/annotations.html#wp1425297

Interface TimerService.createTimer
http://java.sun.com/j2ee/1.4/docs/api/javax/ejb/TimerService.html#createTimer%28long,%20long,%20java.io.Serializable%29

@Local
@Remote
@Stateless(mappedName = "ejb/TestTimer")
public class TestTimerEJB implements TestTimer {


// resources that the container will inject
@Resource
private TimerService timerService;

//inject data source
@Resource(mappedName="jdbc/MyDataSource")
private javax.sql.DataSource datasource;


@Timeout
public void execute(Timer timer) {
System.out.println("Hi from TestTimerEJB timer");
}

Thursday, July 2, 2009

Weblogic 10.3 Enterprise Application decriptors generated by Eclipse Ganymede

application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" id="Application_ID" version="5">
<display-name>
testEAR</display-name>
<module>
<ejb>testEJB.jar</ejb>
</module>
<module>
<web>
<web-uri>testDynamicWeb.war</web-uri>
<context-root>testDynamicWeb</context-root>
</web>
</module>
<library-directory>/lib</library-directory>
</application>


weblogic-application.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-application" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_5.xsd http://www.bea.com/ns/weblogic/weblogic-application http://www.bea.com/ns/weblogic/weblogic-application/1.0/weblogic-application.xsd">
<!-- server-version: 10.3.0 -->
<wls:application-param>
<wls:param-name>webapp.encoding.default</wls:param-name>
<wls:param-value>UTF-8</wls:param-value>
</wls:application-param>
</wls:weblogic-application>


weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
<wls:weblogic-version>10.3.0</wls:weblogic-version>
<wls:container-descriptor>
<wls:prefer-web-inf-classes>false</wls:prefer-web-inf-classes>
</wls:container-descriptor>
<wls:context-root>testDynamicWeb</wls:context-root>
</wls:weblogic-web-app>


web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>testDynamicWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>TestServlet</display-name>
<servlet-name>TestServlet</servlet-name>
<servlet-class>testEAR.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/sayHello</url-pattern>
</servlet-mapping>
</web-app>


ejb-jar.xml
<?xml version="1.0" encoding="ASCII"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
<display-name>testEJB</display-name>
</ejb-jar>


weblogic-ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-ejb-jar xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-ejb-jar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://www.bea.com/ns/weblogic/weblogic-ejb-jar http://www.bea.com/ns/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd">
<!-- server-version: 10.3.0 -->
</wls:weblogic-ejb-jar>

Wednesday, July 1, 2009

SWIFT parser using ANTLR

SWIFT definition http://publib.boulder.ibm.com/infocenter/wbihelp/v6rxmx/index.jsp?topic=/com.ibm.wbia_adapters.doc/doc/swift/swift72.htm
ANTLR http://antlr.org/
ANTLRWorks http://antlr.org/works/index.html
ANTLR Cheet sheet http://www.antlr.org/wiki/display/ANTLR3/ANTLR+Cheat+Sheet

grammar SwiftBlock;

message : block+;

block : '{' '1' ':' expr {System.out.println("expr1=" + $expr.text);} '}' |
'{' '2' ':' expr {System.out.println("expr2=" + $expr.text);} '}' |
'{' '3' ':' expr3* '}' |
'{' '4' ':' expr4+ '}' |
'{' '5' ':' expr5+ '}' ;

expr3 : '{' expr ':' expr '}' {System.out.println("expr3=" + $expr3.text);} ;

expr4 : ('\n'|'\r')+ (':' expr ':' expr {System.out.println("expr4=" + $expr4.text);} | '-')+;

expr5 : ('\n'|'\r')+ '{' expr ':' expr '}' {System.out.println("expr5=" + $expr5.text);} ;

expr : FIELDVALUE* {System.out.println("expr=" + $expr.text);} ;


/*------------------------------------------------------------------
* LEXER RULES
*------------------------------------------------------------------*/

FIELDVALUE : (~('-'|':'|'}'|'{'|'\n'|'\r'))+;


Grammar Interpreter
Syntax Diagram



Parse tree detail


java -cp .:/home/app/antlr-3.1.3/lib/antlr-3.1.3.jar org.antlr.Tool SwiftBlock.g 


import java.io.FileInputStream;

import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CommonTokenStream;

public class AntlrSwiftBlock {
public static void main(String[] args) throws Exception {
FileInputStream fileInputStream = new FileInputStream("/home/dave/workspace/antlrSwift/src/swift.txt");
ANTLRInputStream input = new ANTLRInputStream(fileInputStream);
SwiftBlockLexer lexer = new SwiftBlockLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
SwiftBlockParser parser = new SwiftBlockParser(tokens);
parser.message();
}
}


{1:F01AAAABB99BSMK3513951576}{2:O9400934081223BBBBAA33XXXX03592332770812230834N}{3:{113:xxxx}{108:abcdefgh12345678}}{4:
:20:0112230000000890
:25:SAKG800030155USD
:28C:255/1
:60F:C011223USD175768,92
:61:0112201223CD110,92NDIVNONREF//08 IL053309
/GB/2542049/SHS/312,
:62F:C011021USD175879,84
-}{5:
{CHK:0F4E5614DD28}}


expr=F01AAAABB99BSMK3513951576
expr1=F01AAAABB99BSMK3513951576
expr=O9400934081223BBBBAA33XXXX03592332770812230834N
expr2=O9400934081223BBBBAA33XXXX03592332770812230834N
expr=113
expr=xxxx
expr3={113:xxxx}
expr=108
expr=abcdefgh12345678
expr3={108:abcdefgh12345678}
expr=20
expr=0112230000000890
expr4=
:20:0112230000000890
expr=25
expr=SAKG800030155USD
expr4=
:25:SAKG800030155USD
expr=28C
expr=255/1
expr4=
:28C:255/1
expr=60F
expr=C011223USD175768,92
expr4=
:60F:C011223USD175768,92
expr=61
expr=0112201223CD110,92NDIVNONREF//08 IL053309
expr4=
:61:0112201223CD110,92NDIVNONREF//08 IL053309
line 7:0 required (...)+ loop did not match anything at input '/GB/2542049/SHS/312,'
expr=62F
expr=C011021USD175879,84
expr4=
:62F:C011021USD175879,84
expr=CHK
expr=0F4E5614DD28
expr5=
{CHK:0F4E5614DD28}

MDB 3. 0 on Weblogic 10.3 using Oracle AQ ( Advanced Queue)



package testEAR;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import weblogic.javaee.MessageDestinationConfiguration;

@MessageDestinationConfiguration(connectionFactoryJNDIName = "jms.aq.AQFactory")
@MessageDriven(
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue") },
mappedName = "jms.aq.MY_QUEUE"
)
public class TestMDB implements MessageListener {

public void onMessage(Message message) {
TextMessage txtMsg = null;

txtMsg = (TextMessage) message;
try {
String stringMessage = txtMsg.getText();

System.out.print("Payload: " + stringMessage + "\n");

} catch (JMSException e) {
e.printStackTrace();
}
}
}