question

Upvotes
Accepted
3 0 2 3

EMA Java: Possible to use Batch and View at the same time?

Hi,

I run `example360__MarketPrice__View` and `example370__MarketPrice__Batch`. Both worked fine.

I would like to combine Batch and View to reduce heap consumption.
But the following code, which I tried to merge example360 into example370, leads to an error.

public class Consumer 
{
	public static void main(String[] args)
	{
		OmmConsumer consumer = null;
		try
		{
			AppClient appClient = new AppClient();
			
			consumer  = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host("10.15.1.52:14002").username("new_user"));
			
			OmmArray arrBatch = EmaFactory.createOmmArray();
			arrBatch.add(EmaFactory.createOmmArrayEntry().ascii("/7203.T"));
			arrBatch.add(EmaFactory.createOmmArrayEntry().ascii("/2432.T"));
			ElementList batch = EmaFactory.createElementList();
			batch.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_BATCH_ITEM_LIST, arrBatch));
			
			OmmArray arrayView = EmaFactory.createOmmArray();
			arrayView.fixedWidth(2);
			arrayView.add(EmaFactory.createOmmArrayEntry().intValue(6));
			arrayView.add(EmaFactory.createOmmArrayEntry().intValue(22));
			arrayView.add(EmaFactory.createOmmArrayEntry().intValue(25));
			ElementList view = EmaFactory.createElementList();
			view.add(EmaFactory.createElementEntry().uintValue(EmaRdm.ENAME_VIEW_TYPE, 1));
			view.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_VIEW_DATA, arrayView));


			consumer.registerClient(EmaFactory.createReqMsg().serviceName("ELEKTRON_DD").payload(view).payload(batch), appClient);
			
			Thread.sleep(60000);			// API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg()
		}
		catch (InterruptedException | OmmException excp)
		{
			System.out.println(excp.getMessage());
		}
		finally 
		{
			if (consumer != null) consumer.uninitialize();
		}
	}
}

And the error is:

11 10, 2016 6:38:36 午後 com.thomsonreuters.ema.access.SingleItem rsslSubmit
重大: loggerMsg
    ClientName: SingleItem
    Severity: Error
    Text:    Internal error: rsslChannel.submit() failed in SingleItem.submit(RequestMsg)RsslChannel 0
	Error Id -1
	Internal sysError 0
	Error Location ItemHandler.extractViewFromMsg
	Error Text :ViewData element not found <-26>
loggerMsgEnd

Also, when I swap the order of `.payload(view).payload(batch)` to `.payload(batch).payload(view)`, the error is:

Failed to open or modify item request. Reason: ReactorReturnCodes.FAILURE. Error text: :ItemList not found.
11 10, 2016 6:52:24 午後 com.thomsonreuters.ema.access.SingleItem rsslSubmit
重大: loggerMsg
    ClientName: SingleItem
    Severity: Error
    Text:    Internal error: rsslChannel.submit() failed in SingleItem.submit(RequestMsg)RsslChannel 0
	Error Id -1
	Internal sysError 0
	Error Location WlItemHandler.handleBatchRequest
	Error Text :ItemList not found.
loggerMsgEnd

Could you tell me how to use both Batch and View at the same time?

Thank you.

elektronrefinitiv-realtimeelektron-sdkrrtema-apielektron-message-apibatch
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
11.3k 25 8 13

The Batch and View elementEntry needs to be in the same element list. Please try the following code.

ElementList batchView = EmaFactory.createElementList();

OmmArray arrBatch = EmaFactory.createOmmArray();
arrBatch.add(EmaFactory.createOmmArrayEntry().ascii("/7203.T"));
arrBatch.add(EmaFactory.createOmmArrayEntry().ascii("/2432.T"));
	
OmmArray arrayView = EmaFactory.createOmmArray();
arrayView.fixedWidth(2);
arrayView.add(EmaFactory.createOmmArrayEntry().intValue(6));
arrayView.add(EmaFactory.createOmmArrayEntry().intValue(22));
arrayView.add(EmaFactory.createOmmArrayEntry().intValue(25));

batchView.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_BATCH_ITEM_LIST, arrayBatch));
	
batchView.add(EmaFactory.createElementEntry().uintValue(EmaRdm.ENAME_VIEW_TYPE, 1));
batchView.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_VIEW_DATA, arrayView));

consumer.registerClient(EmaFactory.createReqMsg().serviceName("ELEKTRON_DD").payload(batchView), appClient);
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.

Thank you, it worked!

BTW, what does `1` mean in batchView.add(EmaFactory.createElementEntry().uintValue(EmaRdm.ENAME_VIEW_TYPE, 1)); ?

The ViewType specifies content type of ViewData array. '1' means list of Field ID and '2' means list of Element Name.

In this case and other View for MarketPrice domain items, the View array needs to be list of Field ID, so the ViewType always is '1'.

Below is the related information in the EMA RDM Usage Guide document provided in the EMAJ package.

viewtype.jpg (220.4 KiB)
skajiwara avatar image skajiwara veerapath.rungruengrayubkul

Got it, thank you!

Upvotes
22 7 9 11

@veerapath.rungruengrayubkul ; I would like to use viewType of 2 and it is not working. Basically, I want to request data via standard field names like "ASK", "BID", etc. My domain is "MarketPrice Domain".

Any idea why it is returning all the fields instead? viewType of 1 works when I int fields (22, 25).

Regards,

josa

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.

Click below to post an Idea Post Idea