All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.sii.ogham.sms.sender.impl.cloudhopper.session.AlwaysNewSessionStrategy Maven / Gradle / Ivy

The newest version!
package fr.sii.ogham.sms.sender.impl.cloudhopper.session;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cloudhopper.smpp.SmppSession;

import fr.sii.ogham.core.exception.MessageException;
import fr.sii.ogham.core.exception.clean.CleanException;
import fr.sii.ogham.core.retry.RetryExecutor;
import fr.sii.ogham.sms.builder.cloudhopper.SmppClientSupplier;
import fr.sii.ogham.sms.builder.cloudhopper.SmppSessionHandlerSupplier;
import fr.sii.ogham.sms.message.Sms;
import fr.sii.ogham.sms.sender.impl.cloudhopper.ExtendedSmppSessionConfiguration;
import fr.sii.ogham.sms.sender.impl.cloudhopper.exception.SmppException;

/**
 * Simple management of SMPP session.
 * 
 * For each message:
 * 
    *
  1. Open a SMPP session
  2. *
  3. Send the message
  4. *
  5. Close the SMPP session
  6. *
* *

* Only one message can be sent in the same time. * *

* If an error is raised, the exception is thrown and the SMS is not sent. * * @author Aurélien Baudet * */ public class AlwaysNewSessionStrategy extends BaseSessionHandlingStrategy { private static final Logger LOG = LoggerFactory.getLogger(AlwaysNewSessionStrategy.class); public AlwaysNewSessionStrategy(ExtendedSmppSessionConfiguration configuration, SmppClientSupplier clientSupplier, SmppSessionHandlerSupplier smppSessionHandlerSupplier, RetryExecutor retry) { super(LOG, configuration, clientSupplier, smppSessionHandlerSupplier, retry); } @Override public SmppSession getSession() throws SmppException { destroySession(); destroyClient(); initClient(); initSession(); return currentSession; } @Override public void messageSent(Sms sms) throws MessageException { // nothing to do } @Override public void messageNotSent(Sms sms, SmppException e) throws MessageException { throw new MessageException("Failed to send SMS", sms, e); } @Override public void messageProcessed(Sms sms) { destroySession(); destroyClient(); } @Override public void clean() throws CleanException { destroySession(); destroyClient(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy