Commit 85776023 authored by Andre Freyssinet's avatar Andre Freyssinet

Adds new JMS bridge configuration.

parent 41057a45
......@@ -237,7 +237,7 @@
</target>
<!-- **************************************************
* Bridge tests based on real client configuration
* Bridge tests based on real client configuration #1
************************************************** -->
<!-- EF Bridge server -->
......@@ -290,6 +290,48 @@
</java>
</target>
<!-- **************************************************
* Bridge tests based on real client configuration #2
************************************************** -->
<!-- SEIP Bridge server, /!\ the configuration file is inherited from efbridge -->
<target name="seipbridge_server" depends="simple_init"
description="--> Starts the SEIP bridge server">
<antcall target="server">
<param name="sid" value="1"/>
<param name="a3.conf" value="${conf.dir}/efbridge_a3servers.xml"/>
<param name="osgi.conf" value="${conf.dir}/config_bridge.properties"/>
</antcall>
</target>
<!-- Setup the central server configuration -->
<target name="seipbridge_admin" depends="simple_init"
description="--> Runs the SEIP bridge sample administration">
<java classname="seipbridge.Admin"
failonerror="no" fork="yes"
dir="${run.dir}">
<classpath path="${project.class.path}"/>
</java>
</target>
<!-- Runs the efbridge producer -->
<target name="seipbridge_producer" depends="init"
description="--> Runs the SEIP bridge sample producer">
<java classname="seipbridge.Producer" failonerror="no" fork="yes"
dir="${run.dir}">
<classpath path="${project.class.path}"/>
</java>
</target>
<!-- Runs the efbridge consumer -->
<target name="seipbridge_consumer" depends="init"
description="--> Runs the SEIP bridge sample consumer">
<java classname="seipbridge.Consumer" failonerror="no" fork="yes"
dir="${run.dir}">
<classpath path="${project.class.path}"/>
</java>
</target>
<!-- **************************************************
* Rest samples
************************************************** -->
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2018 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package seipbridge;
import java.util.Properties;
import javax.jms.ConnectionFactory;
import org.objectweb.joram.client.jms.Queue;
import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.JMSAcquisitionQueue;
import org.objectweb.joram.client.jms.admin.JMSDistributionQueue;
import org.objectweb.joram.client.jms.admin.User;
import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory;
public class Admin {
public static void main(String[] args) throws Exception {
System.out.println();
System.out.println("Bridge administration...");
ConnectionFactory bridgeCF = TcpConnectionFactory.create("localhost", 16011);
AdminModule.connect(bridgeCF, "root", "root");
User.create("anonymous", "anonymous");
// Creating a Queue Distribution bridge on bridge server
Queue distq = JMSDistributionQueue.create(0, "distQ", "mqs_dest");
distq.setFreeWriting();
System.out.println("joram distribution queue = " + distq);
// Creating a Queue Acquisition bridge on bridge server
Queue acqq = JMSAcquisitionQueue.create(0, "acqQ", "mqs_dest");
acqq.setFreeReading();
System.out.println("joram acquisition queue = " + acqq);
// bind foreign destination and connectionFactory
Properties jndiProps = new Properties();
jndiProps.setProperty("java.naming.factory.initial", "fr.dyade.aaa.jndi2.client.NamingContextFactory");
jndiProps.setProperty("java.naming.factory.host", "localhost");
jndiProps.setProperty("java.naming.factory.port", "16401");
javax.naming.Context jndiCtx = new javax.naming.InitialContext(jndiProps);
jndiCtx.rebind("distq", distq);
jndiCtx.rebind("acqq", acqq);
jndiCtx.rebind("bridgeCF", bridgeCF);
jndiCtx.close();
AdminModule.disconnect();
System.out.println("Admin closed.");
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2018 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package seipbridge;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.MessageConsumer;
import javax.jms.Session;
/**
* Consumes messages on a foreign destination through the JORAM bridge.
*/
public class Consumer {
public static void main(String[] args) throws Exception {
Properties jndiProps = new Properties();
jndiProps.setProperty("java.naming.factory.initial", "fr.dyade.aaa.jndi2.client.NamingContextFactory");
jndiProps.setProperty("java.naming.factory.host", "localhost");
jndiProps.setProperty("java.naming.factory.port", "16401");
javax.naming.Context jndiCtx = new javax.naming.InitialContext(jndiProps);
Destination bridgeDest = (Destination) jndiCtx.lookup("acqq");
ConnectionFactory bridgeCF = (ConnectionFactory) jndiCtx.lookup("bridgeCF");
jndiCtx.close();
Connection bridgeCnx = bridgeCF.createConnection();
Session bridgeSess = bridgeCnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer bridgeCons = bridgeSess.createConsumer(bridgeDest);
bridgeCons.setMessageListener(new MsgListener("bridge"));
bridgeCnx.start();
System.in.read();
bridgeCnx.close();
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2018 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package seipbridge;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
/**
* Implements the <code>javax.jms.MessageListener</code> interface.
*/
public class MsgListener implements MessageListener {
String who;
public MsgListener(String who) {
this.who = who;
}
public void onMessage(Message msg) {
try {
if (msg instanceof TextMessage)
System.out.println(who + " receive on acquisition queue: " + ((TextMessage) msg).getText());
}
catch (JMSException exc) {
System.err.println("Exception in listener: " + exc);
}
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2018 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package seipbridge;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
/**
* Produces messages on the foreign destination.
*/
public class Producer {
public static void main(String[] args) throws Exception {
Properties jndiProps = new Properties();
jndiProps.setProperty("java.naming.factory.initial", "fr.dyade.aaa.jndi2.client.NamingContextFactory");
jndiProps.setProperty("java.naming.factory.host", "localhost");
jndiProps.setProperty("java.naming.factory.port", "16401");
javax.naming.Context jndiCtx = new javax.naming.InitialContext(jndiProps);
Destination bridgeDest = (Destination) jndiCtx.lookup("distq");
ConnectionFactory bridgeCF = (ConnectionFactory) jndiCtx.lookup("bridgeCF");
jndiCtx.close();
Connection bridgeCnx = bridgeCF.createConnection();
Session bridgeSess = bridgeCnx.createSession(true, 0);
MessageProducer bridgeProducer = bridgeSess.createProducer(bridgeDest);
TextMessage msg = bridgeSess.createTextMessage();
for (int i = 1; i < 11; i++) {
msg.setText("Joram message number " + i + " sent through distribution bridge queue.");
System.out.println("send msg = " + msg.getText());
bridgeProducer.send(msg);
}
bridgeSess.commit();
bridgeCnx.close();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment