M
mike
Hi,
I have the following class MessageManager ( which sends messages in
different formats).
In weblogic 8.1 I use a servelet to call start() and stop() to
activate/deactivate my MessageManager.
How can I activate the 'public void onRecMsg(String msg)'-method when
server is up and running?
Can I use a junit test and execute it in runtime or do I need a
Servlet that calls this method with a message?
Appreciate your advice.
cheers,
//mikael
MessageManager
=============
public class MessageManager implements MessageInterface {
private static MessageQueue msgSession = null;
private int msgFormat = MessageTypes.XML;
private static Logger LOG = Logger.getLogger(MessageManager.class);
public MessageManager(int msgFormat) {
this.msgFormat = msgFormat;
}
public void start() {
try {
if (jmsSession == null) {
msgSession = new MessageQueue();
msgSession.create();
msgSession.setReceiver(McxJndiName.JMS_MSG_QUEUE_NAME,
this);
}
switch (msgFormat) {
case MessageTypes.XML:
sender = new XMLSender();
break;
case MessageTypes.TXT:
sender = new TXTSender();
break;
default:
break;
}
} catch (Exception ex) {
LOG.error("Failed to start " + ex);
stop();
}
}
public void stop() {
try {
if (msgSession != null)
msgSession.close();
} catch (Exception ex) {
LOG.error("Could not close message session" + ex);
}
sender.close();
}
public void onRecMsg(String msg) {
sender.send(msg);
}
}
I have the following class MessageManager ( which sends messages in
different formats).
In weblogic 8.1 I use a servelet to call start() and stop() to
activate/deactivate my MessageManager.
How can I activate the 'public void onRecMsg(String msg)'-method when
server is up and running?
Can I use a junit test and execute it in runtime or do I need a
Servlet that calls this method with a message?
Appreciate your advice.
cheers,
//mikael
MessageManager
=============
public class MessageManager implements MessageInterface {
private static MessageQueue msgSession = null;
private int msgFormat = MessageTypes.XML;
private static Logger LOG = Logger.getLogger(MessageManager.class);
public MessageManager(int msgFormat) {
this.msgFormat = msgFormat;
}
public void start() {
try {
if (jmsSession == null) {
msgSession = new MessageQueue();
msgSession.create();
msgSession.setReceiver(McxJndiName.JMS_MSG_QUEUE_NAME,
this);
}
switch (msgFormat) {
case MessageTypes.XML:
sender = new XMLSender();
break;
case MessageTypes.TXT:
sender = new TXTSender();
break;
default:
break;
}
} catch (Exception ex) {
LOG.error("Failed to start " + ex);
stop();
}
}
public void stop() {
try {
if (msgSession != null)
msgSession.close();
} catch (Exception ex) {
LOG.error("Could not close message session" + ex);
}
sender.close();
}
public void onRecMsg(String msg) {
sender.send(msg);
}
}