|
From: Nik G. <nik...@gm...> - 2021-05-26 09:42:42
|
Ajit,
There is quite a lot wrong with your snippet. Figured it would be easier
to give you an example, so I think this should serve you OK (have not
tested it)...
@Override
public void fromAdmin(final quickfix.Message message, final SessionID
sessionID) throws RejectLogon {
LOG.debug("fromAdmin() : received message={}, sessionID={}", message,
sessionID);
if (message instanceof Logon) {
LOG.debug("checking heartbeat interval for session={}", sessionID);
validateHeartBeatIntervalOrThrowException((Logon) message);
}
}
private void validateHeartBeatIntervalOrThrowException(final Logon
logon) throws RejectLogon {
try {
if (logon.getHeartBtInt().getValue() < 30)
throw new RejectLogon("Heart beat interval must be at least 30
seconds");
}
catch (final FieldNotFound e) {
LOG.error("Field {} not found in logon message {}", e.field,
logon, e);
throw new RejectLogon("Field " + e.field + " must be provided in
Logon message");
}
}
As ever, reading the docs / wiki would help you find this yourself.
Nik
On Wed, 26 May 2021 at 10:19, Christoph John via Quickfixj-users <
qui...@li...> wrote:
> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/
> QuickFIX/J <http://www.quickfixj.org/documentation/QuickFIX/J> Support:
> http://www.quickfixj.org/support/
>
>
> As Nik wrote, you need to use fromAdmin.
>
> There you need to check for Logon messages and the contained Heartbeat
> interval (which is a required field). If it is greater than 30 seconds,
> throw RejectLogon.
>
>
> On 26.05.21 11:06, Ajit Gautam wrote:
>
> Hi,
>
> I tried doing it as per the below methodology :
>
> public void onMessage(Exchange exchange) throws RejectLogon {
> try {
>
> if (MsgType.HEARTBEAT < 30 seconds)
> {
> throw new RejectLogon(Invalid heartbeat);
> }
>
> }
> catch (RejectLogon rejectLogon) {
> throw rejectLogon();
> }
> }
>
> Error - It is throwing me a field exception.
>
> Note: I am receiving all the messages here and I validate all the fields
> in my onMessage method. Let me know If I am doing something wrong.
>
> Regards
> Ajit Gautam
>
>
> On Tue, May 25, 2021 at 9:26 PM Christoph John <chr...@ma...>
> wrote:
>
>> Please read again what Nik suggested.
>>
>> Am 25. Mai 2021 17:40:09 MESZ schrieb Ajit Gautam <
>> aji...@gm...>:
>>>
>>> Hi,
>>>
>>> But to send a rejection, it will require an active session with the
>>> counterparty FIX engine. While, I was thinking not to establish session if
>>> heartbeat time is not greater than 30 seconds.
>>>
>>> Can you please elaborate more on this?
>>>
>>> Regards
>>> Ajit Gautam
>>>
>>> On Tue, May 25, 2021, 20:52 Nik Gehring <nik...@gm...> wrote:
>>>
>>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/
>>>> QuickFIX/J <http://www.quickfixj.org/documentation/QuickFIX/J>
>>>> Support: http://www.quickfixj.org/support/
>>>>
>>>>
>>>> Ajim,
>>>>
>>>> the information you are looking for is shown on
>>>> https://github.com/quickfix-j/quickfixj ...
>>>>
>>>> fromAdmin notifies you when an administrative message is sent from a
>>>>> counterparty to your FIX engine. This can be useful for doing extra
>>>>> validation on Logon messages such as for checking passwords. Throwing
>>>>> a RejectLogon exception will disconnect the counterparty.
>>>>
>>>>
>>>>
>>>> Nik
>>>>
>>>>
>>>> On Tue, 25 May 2021 at 15:38, Ajit Gautam <aji...@gm...>
>>>> wrote:
>>>>
>>>>> QuickFIX/J Documentation: http://www.quickfixj.org/documentation/
>>>>> QuickFIX/J <http://www.quickfixj.org/documentation/QuickFIX/J>
>>>>> Support: http://www.quickfixj.org/support/
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> I was thinking of a scenario of have customised session validation.
>>>>>
>>>>> Scenario -
>>>>> I am building an FIX Acceptor and wanted to allow only session logon
>>>>> with heartbeat time greater than 30 sec. In case of receiving a session
>>>>> logon from initiator with heartbeat time less than 30 seconds, I need to
>>>>> reject the logon.
>>>>> But, Quickfix establishes the session once session logon is accepted.
>>>>>
>>>>> Is there any setting configuration I use on FIX Acceptor or I need to
>>>>> introduce changes in my project code.
>>>>>
>>>>> I was thinking to send business level rejection once session logon is
>>>>> accepted for heartbeat received less than 30 seconds and then send a
>>>>> logout. But still, I can receive a logon again. Thus, I m stuck here.
>>>>>
>>>>> I will appreciate if anyone can provide suggestions on the same.
>>>>>
>>>>>
>>>>> Regards
>>>>> Ajit Gautam
>>>>> _______________________________________________
>>>>> Quickfixj-users mailing list
>>>>> Qui...@li...
>>>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users
>>>>>
>>>> _______________________________________________
>>>> Quickfixj-users mailing list
>>>> Qui...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/quickfixj-users
>>>>
>>>
> --
> Christoph John
> Software Engineering
> T +49 241 557...@ma...
>
> MACD GmbH
> Oppenhoffallee 103
> 52066 Aachen, Germanywww.macd.com
>
> Amtsgericht Aachen: HRB 8151
> Ust.-Id: DE 813021663
> Geschäftsführer: George Macdonald
>
> _______________________________________________
> Quickfixj-users mailing list
> Qui...@li...
> https://lists.sourceforge.net/lists/listinfo/quickfixj-users
>
|