В jsmpp java-библиотеке отдельно привязка на Rx & Tx не работает
Я запускаю простую программу Java, которая использует библиотеку Jsmpp на Binding Rx & Tx отдельно.
В Rx я не получаю DLR, и Tx успешно может опубликовать сообщение.
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.log4j.BasicConfigurator;
import org.jsmpp.bean.AlertNotification;
import org.jsmpp.bean.BindType;
import org.jsmpp.bean.DataSm;
import org.jsmpp.bean.DeliverSm;
import org.jsmpp.bean.DeliveryReceipt;
import org.jsmpp.bean.MessageType;
import org.jsmpp.bean.NumberingPlanIndicator;
import org.jsmpp.bean.TypeOfNumber;
import org.jsmpp.extra.ProcessRequestException;
import org.jsmpp.session.BindParameter;
import org.jsmpp.session.DataSmResult;
import org.jsmpp.session.MessageReceiverListener;
import org.jsmpp.session.SMPPSession;
import org.jsmpp.session.Session;
import org.jsmpp.util.AbsoluteTimeFormatter;
import org.jsmpp.util.InvalidDeliveryReceiptException;
import org.jsmpp.util.TimeFormatter;
public class SmppRx {
private static TimeFormatter timeFormatter = new AbsoluteTimeFormatter();
public static void main(String[] args) {
final AtomicInteger counter = new AtomicInteger();
BasicConfigurator.configure();
final SMPPSession session = new SMPPSession();
try {
session.connectAndBind("xxx.xxx.xxx.xxx", 8056, new BindParameter(BindType.BIND_RX, "test", "test", "cp", TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, null));
} catch (IOException e) {
System.err.println("Failed connect and bind to host");
e.printStackTrace();
}
session.setMessageReceiverListener(new MessageReceiverListener() {
public void onAcceptDeliverSm(DeliverSm deliverSm)
throws ProcessRequestException {
if (MessageType.SMSC_DEL_RECEIPT.containedIn(deliverSm.getEsmClass())) {
counter.incrementAndGet();
try {
DeliveryReceipt delReceipt = deliverSm.getShortMessageAsDeliveryReceipt();
long id = Long.parseLong(delReceipt.getId()) & 0xffffffff;
String messageId = Long.toString(id, 16).toUpperCase();
System.out.println("Receiving delivery receipt for message '" + messageId + "' : " + delReceipt);
} catch (InvalidDeliveryReceiptException e) {
System.err.println("Failed getting delivery receipt");
e.printStackTrace();
}
} else {
System.out.println("Receiving message : " + new String(deliverSm.getShortMessage()));
}
}
public DataSmResult onAcceptDataSm(DataSm dataSm, Session source)
throws ProcessRequestException {
return null;
}
public void onAcceptAlertNotification(
AlertNotification alertNotification) {
}
});
try {
while (true) {
Thread.sleep(1000);
}
} catch (InterruptedException e) {
}
session.unbindAndClose();
}
}
================================================== ========================
import java.io.IOException;
import java.util.Date;
import org.jsmpp.bean.BindType;
import org.jsmpp.bean.DataCodings;
import org.jsmpp.bean.ESMClass;
import org.jsmpp.bean.NumberingPlanIndicator;
import org.jsmpp.bean.RegisteredDelivery;
import org.jsmpp.bean.SMSCDeliveryReceipt;
import org.jsmpp.bean.TypeOfNumber;
import org.jsmpp.session.BindParameter;
import org.jsmpp.session.SMPPSession;
import org.jsmpp.util.AbsoluteTimeFormatter;
import org.jsmpp.util.TimeFormatter;
import org.jsmpp.session.MessageReceiverListener;
import org.jsmpp.bean.AlertNotification;
import org.jsmpp.bean.BindType;
import org.jsmpp.bean.DataSm;
import org.jsmpp.bean.DeliverSm;
import org.jsmpp.bean.NumberingPlanIndicator;
import org.jsmpp.bean.SubmitSmResp;
import org.jsmpp.bean.TypeOfNumber;
import org.jsmpp.session.BindParameter;
import org.jsmpp.session.DataSmResult;
import org.jsmpp.session.MessageReceiverListener;
import org.jsmpp.session.SMPPSession;
import org.jsmpp.session.Session;
import org.jsmpp.util.AbsoluteTimeFormatter;
import org.jsmpp.util.TimeFormatter;
public class SmppTx {
private static TimeFormatter timeFormatter = new AbsoluteTimeFormatter();;
public static void main(String[] args) {
SMPPSession session = new SMPPSession();
session.setMessageReceiverListener(new MessageReceiverListener() {
@Override
public void onAcceptDeliverSm(DeliverSm deliverSm)
{
String dlrString = new String(deliverSm.getShortMessage());
System.out.println("come here "+dlrString);
}
@Override
public void onAcceptAlertNotification(
AlertNotification alertNotification) {
}
@Override
public DataSmResult onAcceptDataSm(DataSm arg0, Session arg1) {
System.out.println("come here ");
return null;
}
// @Override
public void onAcceptSubmitSmResp(SubmitSmResp ssr) {
System.out.println("come here ");
}
});
try {
session.connectAndBind("xxx.xxx.xxx.xxx", 8056, new BindParameter(BindType.BIND_TX, "test", "test", "cp", TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, null));
} catch (IOException e) {
System.err.println("Failed connect and bind to host");
e.printStackTrace();
}
try {
String messageId = session.submitShortMessage("CMT", TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, "SENDER_ID_ANANDH", TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, "8762689682", new ESMClass(), (byte)0, (byte)1, timeFormatter.format(new Date()), , new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT), (byte)0, DataCodings.ZERO , (byte)0, "jSMPP simplify SMPP on Java platform".getBytes());
System.out.println("Message submitted, message_id is " + messageId);
Thread.sleep(2000);
} catch (Exception e) {
System.err.println("Invalid PDU parameter");
e.printStackTrace();
}
session.unbindAndClose();
}
}
Кто-нибудь может мне помочь, что здесь не так? почему я не получаю DLR?