question

Upvotes
Accepted
3 0 0 3

How to handle unsupported events

I am new to using the Java based RFA / OMM api (we currently rely on the jsfc apis)

Looking through the examples on how to handle ItemSubscriptions, I found an interesting piece of code

if (event.getType() != Event.OMM_ITEM_EVENT)

{

System.out.println("ERROR: " + _className + " Received an unsupported Event type."); consumerComponent.cleanup();

return;

}

if I understand this correctly , if an unsupported event type is received, we just shut down the consumer which could affect real time streaming of data. Is this the recommended handling of this kind of event or could we just ignore the event and go on processing next event

My concern is that we shut down consumers altogether, which is unacceptable. We could try restarting them, but if we continuously get the same condition, we could end up in a loop of starting and shutting consumers.

Has anyone encountered this issue before ? Any suggestions are welcome

treprfarfa-apievent-handling
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
1.9k 6 9 16

Hello @parminder.grewal,

In RFA Java (as of version 8.0.1.X), there are various event types as follows:

Event Types	(Constant Value)
---------------------------------
AUTHORIZATION_EVENT	(401)
COMPLETION_EVENT	(2)
CONNECTION_EVENT	(113)
OMM_ACTIVE_CLIENT_SESSION_PUB_EVENT	(125)
OMM_CMD_ERROR_EVENT	(122)
OMM_CONNECTION_EVENT	(129)
OMM_CONNECTION_STATS_EVENT	(130)
OMM_INACTIVE_CLIENT_SESSION_PUB_EVENT	(126)
OMM_ITEM_EVENT	(121)
OMM_LISTENER_EVENT	(124)
OMM_SOLICITED_ITEM_EVENT	(123)
PUB_ERROR_EVENT	(106)
TIMER_EVENT	(3)
UNDEFINED_EVENT	(0)

For an OMMConsumer type of application, you can receive a designate Event Type from registering a corresponding Interest Specifications (IntSpec).

OMMConsumer.registerClient(EventQueue
aQueue, InterestSpec anInterest, Client aClient, java.lang.Object aClosure);

There are four types of IntSpecs that you can put as the argument of OMMConsumer Event Source as follows:

OMMItemIntSpec -> OMMItemEvent

OMMErrorIntSpec -> OMMCmdErrorEvent

OMMConnectionIntSpec -> OMMConnectionEvent

OMMConnectionStatsIntSpec -> OMMConnectionStatsEvent

Furthermore, a COMPLETION_EVENT is a special event of common package. You can switch to receive or not receive this event from this method

Session.createEventSource(int
eventSourceType, java.lang.String name, boolean wCompEvents);

In summary, it is possible that the application can receive more Event Types other than just OMM_ITEM_EVENT.

So, you may need to check how many interest specification(s) that the application has registered (including the COMPLETION_EVENT case). Then, you need to adjust and relax your current logic that checks the Event Types to correspond with the registered interest specification(s).

Alternatively, you may try to debug the incoming event that goes through your logic, check its code (as mentioned above) to identify the Event Type. If you consider it as the unwanted event, you have to review your source code where the application registers surplus interest specification(s). If so, just remove it, restart the application again. The unwanted event(s) should no longer appear anymore.

Hope this helps!

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
9.5k 10 5 7

Hello @parminder.grewal

The example application just demonstrate how to use RFA to consume data.It should be used as a start point to develop an application. In processEvent(..) method which the application processes events including data, what application should do in the method depends on your requirements and it is not necessary to do the same as the example application does. For example, if you would like to continue receiving data even the application receives unsupported event type events, your application can ignore these events instead of shutdown application which the example application does.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
13k 32 12 18

If you are looking to rewrite an application in any aspect, please consider use of Elektron Message API. It is strategic and considerably easy to use. EMA

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

I did look at the EMA api , however while it is more user friendly, it provides lesser visibility. for instance , how do I see the sizes of queues or the age of a message, stuff like this wasnt very clear from the documents or examples.

Click below to post an Idea Post Idea