Cannot set CMP field. SBB entity is null

48 views
Skip to first unread message

BarbosSergos

unread,
Jul 13, 2020, 9:27:41 AM7/13/20
to mobicents-public
Hello,

I'm trying to implement next scenario in processing InitialDP request: 
1. MySbb.onInitialDpRequest() method calls my custom HttpHandler.process() method in which I pass callback.
2. HttpHandler uses Unirest library to send InitialDP to the standalone app (here can be several apps located on different hosts) and process response by passed callback.
3. Response from standalone app contains URL of this app and commands which I should fire on MySbb. For example, request some BCSMRequests and connect to number #C.
4. After receiving BSCMRequestResponse by the corresponding handler, I have to notify the standalone app by requesting it via URL received earlier it step 2.

I was trying to use CMP field appProcessedIdpUrl to store standalone app URL, but I'm facing problem by receiving: 

javax.slee.TransactionRequiredLocalException: Cannot set CMP field. SBB entity is null

I understand that my SBB Entity already transitioned to Pooled state when I receive HttpResponse and can't figure out how to work around and save this URL in SBB Entity, so I can use it for further interaction.

Any help appreciated

Best regards,
Sergey Yashchenkov

Vilius Panevėžys

unread,
Jul 13, 2020, 12:48:11 PM7/13/20
to mobicent...@googlegroups.com
Hi,
some critical details are missing, so I'll take some guesses and you'll
have to correct the unlucky ones. :)

My feeling is that you've tried to improperly integrate a 3rd party
library and use callback-based asynchronicity instead of using events -
the core concept in SLEE.

On Mon, 13 Jul 2020 06:27:41 -0700 (PDT)
BarbosSergos <barbos...@gmail.com> wrote:

> 1. MySbb.onInitialDpRequest() method calls my custom
> HttpHandler.process() method in which I pass callback.

Given that things go wrong eventually, I guess `HttpHandler` is a
simple class, not an RA interface/activity, that does something on a
different thread (-pool). If the thread(s) is started by SBB (even
indirectly) that's already a sin in the SLEE book (see section 12.2.2).
And the next problem is if you pass a reference to the SBB object as
callback to the background process. SBB objects are managed by SLEE, by
the time the response arrives the object (callback) may no longer be
assigned to the SBB entity.

Assuming my guesses were correct, the proper approach would be to use a
Resource Adaptor (I'd look at HTTP client RA) and receive the response
as an event.

If my first guess did not hit the target, gives us some more
information on your HTTP integration approach.

Callbacks can be used in some cases, for example, to report a result
from child SBB to parent by invoking the SBB Local Object interface,
but not by storing a reference to the SBB object itself.


--
Vilius Panevėžys
Elitnet

BarbosSergos

unread,
Jul 14, 2020, 4:00:17 AM7/14/20
to mobicents-public
Hello Vilius,

Yes, you're right, as I wrote in step 2, our HttpHandler uses Unirest to process http requests, not Http client RA.

If I will use Http client RA as you suggested, do you know which performance can handle such architecture? And can you please share any examples of code?
Also do you know how to increase SBB Pool size? Or it doesn't matter to handle high load on this service? For example, 1000-2000 calls per second on one node.

Looking forward to your kind advice.

Best regards,
Sergey Yashchenkov

понедельник, 13 июля 2020 г., 19:48:11 UTC+3 пользователь Vilius Panevėžys написал:

Vilius Panevėžys

unread,
Jul 14, 2020, 5:07:56 AM7/14/20
to mobicent...@googlegroups.com
On Tue, 14 Jul 2020 01:00:17 -0700 (PDT)
BarbosSergos <barbos...@gmail.com> wrote:

> Yes, you're right, as I wrote in step 2, our HttpHandler uses Unirest
> to process http requests, not Http client RA.

Hi Sergey,
given that Unirest runs its own event loop in the background I don't
think it is directly usable by a SLEE service. As an HTTP RA already
exists it is probably not worth reimplementing something similar.

> If I will use Http client RA as you suggested, do you know which
> performance can handle such architecture?

I don't have any performance numbers for HTTP client RA. Even if I had,
performance numbers are not really applicable to a different use case
in a different deployment. You will have to conduct your own performance
tests and measurements.

> And can you please share any examples of code?

SLEE HTTP repo has a REST enabler [1] (an SBB for reuse in a service as
a child SBB), which might be used in some projects under the Restcomm
umbrella, but I don't have a reference offhand. Anyway, it looks
really simple - you should be able to use it even without samples.

> Also do you know how to increase SBB Pool size? Or it doesn't matter
> to handle high load on this service?

I wouldn't worry about the object pool. The first parameters that
you /may/ have to increase to handle high load is the max heap size and
possibly event router threads. But I wouldn't even touch those without
any test results. Twiddling any knob will have side effects. For
example, increasing heap size will likely impact latency due to longer
garbage collections. So there's no magic switch that unlocks
performance, everything has a cost - getting the optimal performance is
a balancing act.

> 1000-2000 calls per second on one node.

That should be doable on a server that's not too old. Unless of course
you hit some implementation detail that effectively linearizes
processing on a single core, which does happen sometimes in practice
but it's fixable. ;)


[1]
https://github.com/RestComm/jain-slee.http/tree/master/enablers/rest-client


--
Vilius Panevėžys
Elitnet

BarbosSergos

unread,
Jul 14, 2020, 5:47:36 AM7/14/20
to mobicents-public
Thank you so much!
I already found some old docs for mobicents Http Client RA, and will try to implement this architecture with Http Client RA.

Maybe you can help with other questions that I have :)

Is it possible to handle service deactivate event?
Is there any approach to create "Singleton services" which will be available for other SBB. For example, service that can wrap settings, update them from DB or settings file, and these settings can be read\shared with others SBBs?


Best regards,
Sergey Yashchenkov

вторник, 14 июля 2020 г., 12:07:56 UTC+3 пользователь Vilius Panevėžys написал:

Vilius Panevėžys

unread,
Jul 14, 2020, 7:18:27 AM7/14/20
to mobicent...@googlegroups.com
On Tue, 14 Jul 2020 02:47:35 -0700 (PDT)
BarbosSergos <barbos...@gmail.com> wrote:

> Is it possible to handle service deactivate event?

Activity End Event on Service Activity. Although, it's rarely useful,
in my experience.

> Is there any approach to create "Singleton services" which will be
> available for other SBB. For example, service that can wrap settings,
> update them from DB or settings file, and these settings can be
> read\shared with others SBBs?

That's not a valid approach, take a good look at the restrictions
section that I've already mentioned (12.2) in the SLEE spec (an SBB may
not access the file system, use threads, sockets, etc.). It may sound
like arbitrary restrictions getting in the way of implementing real
world use cases, but when you view the SLEE model as a whole, it
becomes clear those very restrictions are the necessary assumptions
that enable the advantages of SLEE. If you don't play by the book, you
may find yourself chasing hard to diagnose problems, the "impossible"
things start happening. :) So perusing the spec is actually a time
saving investment. ;)

The obvious solution for the config provider, whatever the source, is
an RA. Anyway, if you don't see the value of SLEE in the case you're
working on, there's life beyond SLEE. :) Play a game by the rules, if
you don't like the rules - find a different game.


--
Vilius Panevėžys
Elitnet
Reply all
Reply to author
Forward
0 new messages