From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../src/examples/messaging/dd/LogBean.java | 22 ++++++++++++++ .../src/examples/messaging/dd/LogClient.java | 34 ++++++++++++++++++++++ .../src/examples/messaging/dd/META-INF/ejb-jar.xml | 19 ++++++++++++ .../examples/messaging/dd/META-INF/sun-ejb-jar.xml | 13 +++++++++ .../src/examples/messaging/dd/build.xml | 30 +++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/LogBean.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/LogClient.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/META-INF/ejb-jar.xml create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/META-INF/sun-ejb-jar.xml create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/build.xml (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd') diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/LogBean.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/LogBean.java new file mode 100644 index 0000000..89364d9 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/LogBean.java @@ -0,0 +1,22 @@ +package examples.messaging.dd; + +import javax.jms.*; + +public class LogBean implements MessageListener { + + public LogBean() { + } + + public void onMessage(Message msg) { + if (msg instanceof TextMessage) { + TextMessage tm = (TextMessage) msg; + try { + String text = tm.getText(); + System.err.println("Received new message : " + text); + } catch (JMSException e) { + e.printStackTrace(); + } + } + } + +} \ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/LogClient.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/LogClient.java new file mode 100644 index 0000000..14b6008 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/LogClient.java @@ -0,0 +1,34 @@ +package examples.messaging.dd; + +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; +import javax.jms.TopicConnection; +import javax.jms.TopicConnectionFactory; +import javax.jms.TopicPublisher; +import javax.jms.TopicSession; +import javax.naming.InitialContext; + +public class LogClient { + + public static void main(String[] args) throws Exception { + InitialContext ctx = new InitialContext(System.getProperties()); + + Topic topic = (Topic) ctx.lookup("jms/Topic"); + TopicConnectionFactory factory = + (TopicConnectionFactory) ctx + .lookup("jms/TopicConnectionFactory"); + TopicConnection connection = factory.createTopicConnection(); + TopicSession session = connection.createTopicSession(false, + Session.AUTO_ACKNOWLEDGE); + + TopicPublisher publisher = session.createPublisher(topic); + + // create and publish a message + TextMessage msg = session.createTextMessage(); + msg.setText("This is a test message."); + publisher.publish(msg); + + System.out.println("Message published. Please check application server's console to see the response from MDB."); + } +} \ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/META-INF/ejb-jar.xml b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/META-INF/ejb-jar.xml new file mode 100644 index 0000000..92cee32 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/META-INF/ejb-jar.xml @@ -0,0 +1,19 @@ + + + + + LogBeanDD + examples.messaging.dd.LogBean + javax.jms.MessageListener + Bean + javax.jms.Topic + + + + destinationType + javax.jms.Topic + + + + + \ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/META-INF/sun-ejb-jar.xml b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/META-INF/sun-ejb-jar.xml new file mode 100644 index 0000000..85caf26 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/META-INF/sun-ejb-jar.xml @@ -0,0 +1,13 @@ + + + + LogBeanDD + + LogBeanDD + jms/Topic + + jms/TopicConnectionFactory + + + + diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/build.xml b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/build.xml new file mode 100644 index 0000000..b6b0013 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/messaging/dd/build.xml @@ -0,0 +1,30 @@ + + ]> + + + + + + + + + + + + + + + + &include; + + + + + + + + + + -- cgit v1.2.3