Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct way to configure a connection with 5 SMPP sessions (binds) #12

Open
menwn opened this issue Jun 28, 2017 · 0 comments
Open

Correct way to configure a connection with 5 SMPP sessions (binds) #12

menwn opened this issue Jun 28, 2017 · 0 comments

Comments

@menwn
Copy link

menwn commented Jun 28, 2017

I cannot understand the comments in the examples and the code

Creates a new default SmppClient.
* @param workerGroup The max number of concurrent sessions expected
* to be active at any time. This number controls the max number of worker
* threads that the underlying Netty library will use. If processing
* occurs in a sessionHandler (a blocking op), be VERY careful
* setting this to the correct number of concurrent sessions you expect.

If I want to connect to a SMSC over 5 binds (smpp sessions) what I am doing is this:

   public void configure(MessageForwardingService  messageForwardingService,
		         MessageLoggingService messageLoggingService) {
	int sessionNum = connectionProperties.get(ConnectionConstants.OPERATOR_CONNECTION_SESSION_NUMBER, 0);

	final SmppClientMessageService smppClientMessageService = new CommXPSmppClientMessageService(operatorName,
			messageForwardingService, messageLoggingService, applicationEventPublisher);
	for (int i = 0; i < sessionNum; i++) {
		OutboundClient client = new OutboundClient(
				connectionProperties.get(ConnectionConstants.OPERATOR_CONNECTION_ENQUIRELINK_TIMER, 10000),
				connectionProperties.get(ConnectionConstants.OPERATOR_CONNECTION_ENQUIRELINK_TIMER, 30000));
		client.initialize(getSmppConnectionConfiguration(i), smppClientMessageService);
		balancedList.set(client, 1);
	}
}

 public OutboundClient(final Integer endquireLinkPeriod, Integer enquireLinkTimeout) {
	            this.enquireLinkPeriod = endquireLinkPeriod;
	           this.enquireLinkTimeout = enquireLinkTimeout;
	            this.enquireLinkExecutor = Executors.newScheduledThreadPool(1, new ThreadFactory() {

		@Override
		public Thread newThread(Runnable r) {
			Thread t = new Thread(r);
			String name = config.getName();
			t.setName("EnquireLink-" + name);
			return t;
		}
	});

	monitorExecutor = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(1, new ThreadFactory() {

		private AtomicInteger sequence = new AtomicInteger(0);

		@Override
		public Thread newThread(Runnable r) {
			Thread t = new Thread(r);
			t.setName("SmppClientSessionWindowMonitorPool-" + sequence.getAndIncrement());
			return t;
		}
	});

	NioEventLoopGroup group = new NioEventLoopGroup(1);
	clientBootstrap = new DefaultSmppClient(group, monitorExecutor);
}

public void initialize(SmppSessionConfiguration config, SmppClientMessageService smppClientMessageService) {
	this.config = config;
	logger = LoggerFactory.getLogger(OutboundClient.class.getCanonicalName() + config.getName());
	//
	// setup configuration for a client session
	//
	sessionHandler = new ClientSmppSessionHandler(this, smppClientMessageService);
}`

Then I get each of the balancedList sessions and I submitMessages.
To my mind this is creating 5 different DefaultClients with 1 thread each. Somehow though this seems counter intuitive and I am not sure it is correct.

It works and I had great success submitting with over 200 TPS but I am worried since I started facing an issue with very heavy load for incoming messages. Is the problem related to using the sessions incorrectly or should I look elsewhere for the issue?

I know that opening an issue might not be ideal but given the limited documentation I have found on cloudhopper I thought this could be a good opportunity to add some explanation to the code samples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant