Dear Vilius,
Please find below code & descriptor, there is one timer event that prints a text in logger & there is one deliver SM event.
Code:
package org.mobicents.slee.smpp.test;
import java.io.IOException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.slee.*;
import javax.slee.facilities.Tracer;
import net.java.slee.resources.smpp.*;
import net.java.slee.resources.smpp.SmppSession;
import net.java.slee.resources.smpp.SmppTransaction;
import net.java.slee.resources.smpp.SmppTransactionACIFactory;
import net.java.slee.resources.smpp.pdu.SubmitSM;
import org.mobicents.slee.*;
import net.java.slee.resources.smpp.pdu.Address;
import net.java.slee.resources.smpp.pdu.SmppRequest;
import net.java.slee.resources.smpp.pdu.SmppResponse;
import javax.slee.facilities.TimerEvent;
import javax.slee.facilities.TimerFacility;
import javax.slee.facilities.TimerOptions;
import javax.slee.facilities.TimerPreserveMissed;
import javax.slee.SbbContext;
public abstract class SMPPSbb implements Sbb, SMPP {
private Tracer tracer;
private TimerFacility timerFacility;
private static TimerOptions timerOptions;
SmppTransactionACIFactory smppAcif;
SmppSession smppSession;
SubmitSM submitSm;
private SbbContextExt sbbContext; // This SBB's SbbContext
public void onServiceStartedEvent(javax.slee.serviceactivity.ServiceStartedEvent event, ActivityContextInterface aci) {
tracer.info("Service Started ...");
setTimer(aci);
}
private TimerOptions getTimerOptions(){
if (timerOptions == null){
timerOptions = new TimerOptions();
timerOptions.setPreserveMissed(TimerPreserveMissed.ALL);
}
return timerOptions;
}
private void setTimer(ActivityContextInterface aci){
timerFacility.setTimer(aci, null, System.currentTimeMillis() + 30000L, getTimerOptions());
}
public interface SmppTransactionACIFactory {
javax.slee.ActivityContextInterface getActivityContextInterface(SmppTransaction txn);
}
public void onTimerEvent(javax.slee.facilities.TimerEvent event, ActivityContextInterface aci) {
tracer.info("this is timer event");
this.setTimer(aci);
public void setSbbContext(SbbContext context) {
this.sbbContext = (SbbContextExt) context;
tracer = context.getTracer(this.getClass().getSimpleName());
this.timerFacility = this.sbbContext.getTimerFacility();
try {
Context myEnv = (Context) new InitialContext().lookup("java:comp/env");
smppSession = (SmppSession) myEnv.lookup("slee/resources/smpp/5.0/smppSession");
smppAcif = (SmppTransactionACIFactory) myEnv.lookup("slee/resources/smpp/5.0/factoryprovider");
} catch (NamingException ne) {
tracer.info("Could not set SBB context:" + ne.getMessage());
}
}
public void unsetSbbContext() { this.sbbContext = null; }
// TODO: Implement the life cycle methods if required
public void sbbCreate() throws javax.slee.CreateException {}
public void sbbPostCreate() throws javax.slee.CreateException {}
public void sbbActivate() {}
public void sbbPassivate() {}
public void sbbRemove() {}
public void sbbLoad() {}
public void sbbStore() {}
public void sbbExceptionThrown(Exception exception, Object event, ActivityContextInterface activity) {}
public void sbbRolledBack(RolledBackContext context) {}
/**
* Convenience method to retrieve the SbbContext object stored in setSbbContext.
*
* TODO: If your SBB doesn't require the SbbContext object you may remove this
* method, the sbbContext variable and the variable assignment in setSbbContext().
*
* @return this SBB's SbbContext object
*/
protected SbbContextExt getSbbContext() {
return sbbContext;
}
public void onDELIVER_SM(net.java.slee.resources.smpp.pdu.DeliverSM event, ActivityContextInterface aci) {
tracer.info("Received Message...");
}
}
Descriptor:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE sbb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD JAIN SLEE SBB 1.1//EN"
"
http://java.sun.com/dtd/slee-sbb-jar_1_1.dtd">
<sbb-jar>
<sbb>
<description/>
<sbb-name>SMPP</sbb-name>
<sbb-vendor>org.mobicents</sbb-vendor>
<sbb-version>1.0</sbb-version>
<sbb-classes>
<sbb-abstract-class>
<sbb-abstract-class-name>org.mobicents.slee.smpp.test.SMPPSbb</sbb-abstract-class-name>
</sbb-abstract-class>
</sbb-classes>
<event event-direction="Receive" initial-event="True">
<event-name>ServiceStartedEvent</event-name>
<event-type-ref>
<event-type-name>javax.slee.serviceactivity.ServiceStartedEvent</event-type-name>
<event-type-vendor>javax.slee</event-type-vendor>
<event-type-version>1.0</event-type-version>
</event-type-ref>
<initial-event-select variable="ActivityContext"/>
</event>
<event event-direction="Receive" initial-event="False">
<event-name>TimerEvent</event-name>
<event-type-ref>
<event-type-name>javax.slee.facilities.TimerEvent</event-type-name>
<event-type-vendor>javax.slee</event-type-vendor>
<event-type-version>1.0</event-type-version>
</event-type-ref>
</event>
<event event-direction="Receive" initial-event="False">
<event-name>DELIVER_SM</event-name>
<event-type-ref>
<event-type-name>net.java.slee.resources.smpp.DELIVER_SM</event-type-name>
<event-type-vendor>net.java</event-type-vendor>
<event-type-version>5.0</event-type-version>
</event-type-ref>
</event>
<resource-adaptor-type-binding>
<resource-adaptor-type-ref>
<resource-adaptor-type-name>SMPPResourceAdaptorType</resource-adaptor-type-name>
<resource-adaptor-type-vendor>net.java</resource-adaptor-type-vendor>
<resource-adaptor-type-version>5.0</resource-adaptor-type-version>
</resource-adaptor-type-ref>
<activity-context-interface-factory-name>slee/resources/smpp/5.0/factoryprovider</activity-context-interface-factory-name>
<resource-adaptor-entity-binding>
<resource-adaptor-object-name>slee/resources/smpp/5.0/smppSession</resource-adaptor-object-name>
<resource-adaptor-entity-link>SmppRA</resource-adaptor-entity-link>
</resource-adaptor-entity-binding>
</resource-adaptor-type-binding>
</sbb>
</sbb-jar>
Error:
17:50:36,223 INFO [SleeManagementMBean] >< >< >< >< >< >< >< Mobicents JAIN SLEE 2.6.0.FINAL "GANDHI" starting >< >< >< >< >< >< ><
17:50:36,260 INFO [SleeManagementMBean] >< >< >< >< >< >< >< Mobicents JAIN SLEE 2.6.0.FINAL "GANDHI" started >< >< >< >< >< >< ><
17:50:36,273 INFO [SmppResourceAdaptor] setFaultTolerantResourceAdaptorContext(FaultTolerantResourceAdaptorContext arg0)
17:50:36,273 INFO [SmppResourceAdaptor] Activation RA SmppRA
17:50:36,412 INFO [TcpLink] Opening TCP socket to /
10.98.136.13:501617:50:36,625 INFO [Session-1] SMSC did not supply SC_INTERFACE_VERSION. Disabling optional parameter support.
17:50:36,626 INFO [SmppResourceAdaptor] Successfully bound to SMSC.
17:50:36,738 INFO [SMPPSbbImpl] Trying to set up context ....
17:50:36,747 ERROR [SbbEntityImpl] Failed to assign and create sbb object
java.lang.ClassCastException: net.java.slee.resources.smpp.SmppTransactionACIFactoryImpl cannot be cast to org.mobicents.slee.smpp.test.SMPPSbb$SmppTransactionACIFactory
at org.mobicents.slee.smpp.test.SMPPSbb.setSbbContext(SMPPSbb.java:165)
at org.mobicents.slee.runtime.sbb.SbbObjectImpl.<init>(SbbObjectImpl.java:137)
at org.mobicents.slee.runtime.sbb.SbbObjectPoolFactory.makeObject(SbbObjectPoolFactory.java:146)
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:974)
at org.mobicents.slee.runtime.sbb.SbbObjectPoolImpl.borrowObject(SbbObjectPoolImpl.java:68)
at org.mobicents.slee.runtime.sbbentity.SbbEntityImpl.assignSbbObject(SbbEntityImpl.java:732)
at org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskImpl.routeQueuedEvent(EventRoutingTaskImpl.java:360)
at org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskImpl.run(EventRoutingTaskImpl.java:126)
at org.mobicents.slee.runtime.eventrouter.EventRouterExecutorImpl$EventRoutingTaskStatsCollector.run(EventRouterExecutorImpl.java:73)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
17:50:36,763 ERROR [EventRoutingTaskImpl] Caught exception while routing EventContext[event type id = EventTypeID[name=javax.slee.serviceactivity.ServiceStartedEvent,vendor=javax.slee,version=1.0] , event =
org.mobicents.slee.container.service.ServiceStartedEventImpl@1ab5ffa , local ac = ACH=SERVICE>ServiceID[name=SMPP,vendor=org.mobicents,version=1.0] , address = null , serviceID = null]
java.lang.ClassCastException: net.java.slee.resources.smpp.SmppTransactionACIFactoryImpl cannot be cast to org.mobicents.slee.smpp.test.SMPPSbb$SmppTransactionACIFactory
at org.mobicents.slee.smpp.test.SMPPSbb.setSbbContext(SMPPSbb.java:165)
at org.mobicents.slee.runtime.sbb.SbbObjectImpl.<init>(SbbObjectImpl.java:137)
at org.mobicents.slee.runtime.sbb.SbbObjectPoolFactory.makeObject(SbbObjectPoolFactory.java:146)
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:974)
at org.mobicents.slee.runtime.sbb.SbbObjectPoolImpl.borrowObject(SbbObjectPoolImpl.java:68)
at org.mobicents.slee.runtime.sbbentity.SbbEntityImpl.assignSbbObject(SbbEntityImpl.java:732)
at org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskImpl.routeQueuedEvent(EventRoutingTaskImpl.java:360)
at org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskImpl.run(EventRoutingTaskImpl.java:126)
at org.mobicents.slee.runtime.eventrouter.EventRouterExecutorImpl$EventRoutingTaskStatsCollector.run(EventRouterExecutorImpl.java:73)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Br,
./Qasim