java - 将列 append 到 QuickFix/J Logs 数据库(自定义 QuickFix/J Logger)

标签 java database append quickfix quickfixj

QuickFix/J 提供将其日志存储在数据库中的功能。

是否可以将另一列(业务 ID) append 到其中一个表中,从而不会在 QuickFix/J 的内部消息日志记录中造成问题?

如果可能的话,请提及执行此操作的程序。

最佳答案

解决方案是创建您自己的 Logger 和 LoggerFactory,类似于 QuickFix/J 提供的 Logger 和 LoggerFactory。

您可以通过实现“quickfix.Log”接口(interface)创建Logger,并通过实现“quickfix.LogFactory”接口(interface)创建LoggerFactory。

最简单的方法是使用 QuickFix/J 中的私有(private) AbstractLog。

创建 Log 类:

  1. Copy the AbstractLog class as it is from QuickFix/J's source and include it in your project.
  2. Create a class which extends the AbstractLog class and implement all the abstract methods.
  3. Create member variables for any extra field you want to append to the logs (e.g. business ID), and provide a constructor which takes is as an argument and sets its value.
  4. The "logIncoming" and "logOutgoing" methods take a String parameter. This is the data you want to log. At this point you can append your own fields (added in point 3) to the logs. You can format the log as you wish and you are free to use any method of output, i.e. Console, database etc. as you will have to implement it yourself.

创建 LoggerFactory:

  1. Create a LoggerFactory that implements the quickfix.LogFactory interface.

  2. In the "create" method, create and return the instance of the Logger you created before using the constructor you require.

  3. The values that you need to be passed to the constructor can be kept as member variables of the LoggerFactory and set in LoggerFactory's constructor.

您现在有一个自定义记录器,可以使用它,因为使用了 QuickFix/J 自己的记录器,并且 QuickFix/J 将自动使用您的记录器进行记录。

ApplicationAdapter application = new FixInitiator();
SessionSettings settings = new SessionSettings("./config/initiator.cfg");
CustomLogFactory customLogFactory = new CustomLogFactory(settings, myCustomID);
DefaultMessageFactory messageFactory = new DefaultMessageFactory();
FileStoreFactory fileStoreFactory = new FileStoreFactory(settings);
socketInitiator = new SocketInitiator(application, fileStoreFactory, settings, customLogFactory, messageFactory);
socketInitiator.start(); 

查看 QuickFix/J 自己的 Logger 和 LoggerFactory 实现来寻求帮助将是一个好主意。 例如登录控制台的Logger:ScreenLog , ScreenLogFactory

QuickFix/J 来源:

https://github.com/quickfix-j/quickfixj

关于java - 将列 append 到 QuickFix/J Logs 数据库(自定义 QuickFix/J Logger),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33033629/

相关文章:

java - LDAP 身份验证问题

java - 在 JTextArea 的字符串中设置多种文本颜色

mysql - 在 SQL 中使用 COUNT(Distinct)

javascript - 单击时为每个按钮添加/删除 div

jQuery: append 和替换内容

java - 需要 java 系统调用方面的帮助

java - 从java代码更改开关图标颜色

mysql - 选择所有 ORDER BY View 并使每 3 个项目随机

sql-server - 从同一个表中选择按时间分组的多个计数

javascript - JQUERY 下拉 Div 问题