question

Upvotes
Accepted
3 0 0 4

Attempt to use invalid Handle on submit(PostMsg)

Hi,


I am trying to post a message on RTMDS connectivity (no tunnel stream), but the response to the post request is this error message


2023-05-23 10:44:52.704 ERROR 37860 --- [pool-2-thread-1] c.refinitiv.ema.access.OmmConsumerImpl : loggerMsg

ClientName: ItemCallbackClient

Severity: Error

Text: Attempt to use invalid Handle on submit(PostMsg). Instance name='EmaConsumer_1'.

loggerMsgEnd



Sample code:

...

try {

System.out.println("Contributing to Refinitiv Contributions Channel");


//Parsing Program arguments.

OmmConsumerConfig config = EmaFactory.createOmmConsumerConfig();


Common.readCommandlineArgs(args,config);

if (Common.userName != null) config.username(Common.userName);

_ommConsumer = EmaFactory.createOmmConsumer(config.host(Common.host));


//Register to get the login and source directory message

Login.LoginReq loginReq = EmaFactory.Domain.createLoginReq();


_ommConsumer.registerClient(loginReq.message(), this);


_ommConsumer.registerClient(EmaFactory.createReqMsg().domainType(EmaRdm.MMT_DIRECTORY).serviceName(trceServiceName), this);


Thread.sleep(60000);

} catch (InterruptedException | OmmException excp) {

System.out.println(excp.getMessage());

}

...


@Override


public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event) {

try {

System.out.println("----- Refresh message ----");


System.out.println(refreshMsg);


if (refreshMsg.domainType() == EmaRdm.MMT_LOGIN && refreshMsg.state().streamState() == OmmState.StreamState.OPEN && refreshMsg.state().dataState() == OmmState.DataState.OK) {


// 3. Login accepted, app can post data now


System.out.println("Login accepted, starting posting...");


_postStreamID = refreshMsg.streamId();

postMessage();

} else {

System.out.println("Stream not open");

}

} catch (OmmException excp) {

System.out.println(excp.getMessage());

}

}



...


private void postMessage() {

try {

Thread.sleep(300);

} catch (Exception e) {


}


// populate the contributed FIDs and values

FieldList nestedFieldList = EmaFactory.createFieldList();

nestedFieldList.add(EmaFactory.createFieldEntry().real(22, _bid++, OmmReal.MagnitudeType.EXPONENT_NEG_1));

nestedFieldList.add(EmaFactory.createFieldEntry().real(25, _ask++, OmmReal.MagnitudeType.EXPONENT_NEG_1));


// create an update message for our item


UpdateMsg nestedUpdateMsg = EmaFactory.createUpdateMsg()

.streamId(_postStreamID)

.name(trceItem)

.payload(nestedFieldList);


// post this market price message

_ommConsumer.submit(EmaFactory.createPostMsg()

.streamId(_postStreamID)

.postId(_postID++)

.domainType(EmaRdm.MMT_MARKET_PRICE)

.solicitAck(true)


.complete(true)


.payload(nestedUpdateMsg), _subStreamHandle);


}


....


Any idea?

#technologyema-apiposting
icon clock
10 |1500

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

Upvote
Accepted
86.2k 292 53 79

@jasequeirosa

What values would you like to post?

For example, if I would like to send 123.50 and 456.50, the code looks like this:

        nestedFieldList.add(EmaFactory.createFieldEntry().real(22, 12350, OmmReal.MagnitudeType.EXPONENT_NEG_2));
        nestedFieldList.add(EmaFactory.createFieldEntry().real(25, 45650, OmmReal.MagnitudeType.EXPONENT_NEG_2));

The output is:

1685090670835.png



1685090670835.png (12.5 KiB)
icon clock
10 |1500

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

Upvote
24.8k 64 15 21

Hi @jasequeirosa,

Please try to run the Example 341 - offstream posting from EMA SDK, and let us know if you still have issues. Your example is incomplete and I don't know what _subStreamHandle is pointing to.

icon clock
10 |1500

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

Upvote
86.2k 292 53 79

@jasequeirosa

I assume that you are contributing data to RCC. You can refer to the sample code in the EMA Consumer - Posting data to Contribution Channel tutorial.

According to the error message, it looks like the handle or stream used by the application to contribute the data has been closed.

You may need to enable tracing in the API to verify what the problem is. You can set the XmlTraceToStdout to 1 in the consumer used by the application. For example:

        <Consumer>            
            <Name value="Consumer_1"/>            
            <Channel value="Channel_1"/>
            <Dictionary value="Dictionary_1"/>
            <XmlTraceToStdout value="1"/>
        </Consumer>


icon clock
10 |1500

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

Upvotes
3 0 0 4

Hi,

I found the problem. On the one hand, I was using the wrong service, since I was using the contributing service incorrectly, and on the other hand, I was not using the correct type of message to publish prices.

On the other hand, now I have a problem posting decimals for the bid/ask, how do I send decimals?


    public void postMessage(BidAsk bidAsk) {
        PostMsg postMsg = EmaFactory.createPostMsg();
        UpdateMsg nestedRefreshMsg = EmaFactory.createUpdateMsg();
        FieldList nestedFieldList = EmaFactory.createFieldList();

        //FieldList is a collection in java
        nestedFieldList.add(EmaFactory.createFieldEntry().real(22, bidAsk.getBid().longValue(), OmmReal.MagnitudeType.EXPONENT_POS_1));
        nestedFieldList.add(EmaFactory.createFieldEntry().real(25, bidAsk.getAsk().longValue(), OmmReal.MagnitudeType.EXPONENT_POS_1));

        nestedRefreshMsg.payload(nestedFieldList);

        consumer.submit(postMsg.postId(postId++).serviceName("Service")
                .name((bidAsk.getItemName().substring(0, 3))+ Constants.LH_CAIX).solicitAck(true).complete(true)
                .payload(nestedRefreshMsg), eventHandle);
    }


Thanks

icon clock
10 |1500

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

Upvotes
3 0 0 4

Hi,


Ok, thanks, it`s works!


Best regards

icon clock
10 |1500

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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