Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Time since last message

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Time since last message

    Apologies if I'm delving into something that's already been discussed here, I searched until I turned blue in the face and couldn't find anything. Pointers to the appropriate resources will always be welcome.

    We finally brought our first Mirth engine online this week, and I can already see a couple of things "missing". For example, I want a column in the dashboard that shows me time elapsed since the last successful send.

    I want it done properly - I don't want to hack it with javascript, a fake channel, file timestamps or any of the other ingenious methods others have tried over the years - so I download the source, install eclipse, outrageously steal all the best bits from plugins.dashboardstatus and compile. Excellent. I have my own custom column in the dashboard.

    Now I just need to populate the relevant data...and I hit a brick wall. The engine doesn't appear to actually track this value anywhere...and while I'm certainly capable of extending the dashboardstatus plugin, I don't want to modify any existing code. I want to try and create a complete standalone plugin that I can share and can be just dropped in. (so others don't have to go through the extreme pain I just had to suffer trying to figure out how to create a plugin with almost zero documentation on the subject....*coughhinthintcough*)

    Right now, the only thing I can seem to come up with is to parse the events log, and look for the timestamp on the most recent SENT event for each channel...and that seems like a huge waste of effort. I can't help feel like there has to be an easier way.

    Am I missing something obvious?

    Thanks.

  • #2
    I'm assuming you've been working with DashboardColumnPlugin then right? Basically you will want to do it the same way DashboardConnectorStatusColumn works. Whenever the tableUpdate method gets called, the column plugin invokes the "getStates" method through the REST servlet. Since it's a call to a plugin service, the extension controller handles the invocation; in this case it eventually gets down to DashboardConnectorStatusMonitor.invoke. Here, you can see:

    Code:
    if (method.equals(METHOD_GET_STATES)) {
                return connectorStateMap;
                ...
    That map gets serialized and sent back over the wire to the client in DashboardConnectorStatusColumn, where it gets stored as a private field. It's then used later in getTableData when the dashboard table refreshes:

    Code:
    if (currentStates != null && currentStates.containsKey(connectorName)) {
        String[] stateData = currentStates.get(connectorName);
        return new CellData(iconMap.get(stateData[0]), stateData[1]);
    } else {
        return new CellData(blackBullet, "Unknown");
    }
    So, you'd probably want to follow a similar paradigm. In addition to your DashboardColumnPlugin extension, you'll want to make implementations of ConnectorStatusPlugin and ServicePlugin (it could be the same class, or it could be two separate ones, up to you). Then in the invoke method, return some object that will be useful to you (e.g. a Calendar or DateTime object, or maybe something more complex, again up to you).

    Notice how ConnectorStatusPlugin has that updateStatus method? That's where you grab information from the server about whether a connector has sent a message or not. In general, the BUSY event means that a connector is currently processing a message through its endpoint, and DONE means that it's no longer processing a message through (you don't know here whether the message was successful or not though).

    Finally, use your custom extension of DashboardColumnPlugin to invoke your plugin servlet during tableUpdate, store the data, and use it in the getTableData method. Make sure you have a proper cell renderer set too (there's already a DateCellRenderer in client/ui you can use).

    We'll get around to plugin documentation sometime... haha.


    EDIT: Just FYI, the suggestions here pertain to version 2 (tags/2.2.2, or branches/2.x for the latest 2.x line build), not version 3 (which is under trunk). In 3.0 it'll be almost the same though.
    Last edited by narupley; 06-12-2013, 09:43 PM.
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment


    • #3
      Thanks, Nick. That's what I was basically planning, I was just running into the problem of being able to tell when the channel had sent something - as far as I can tell, updateStatus goes to check the status at the actual time of the dashboard refresh which is fine if you want a live view - I don't, I want to know when it LAST sent, and if my dashboard is refreshing every ten seconds, I could send a couple hundred messages and never find out...I'd purely be looking at a column called "Time I last saw a message in the middle of being sent".

      That's what I was talking about checking the message log or something similar - somewhere where there is an actual persistant record that something happened and it was okay - I believe that if I manually search the channel messages for any message with a status of RECEIVED|ACCEPTED|FILTERED|TRANSFORMED, set the page size to 1 then look at the DateTime for the single returned record then I'd get the result I want... so I'm assuming I'm going to have to tap into MessageListHandler. At least the search seems to be nice and responsive with a page size of 1, but then again we've only got two channels with a thousand messages in each right now, lol.

      I just wanted to check whether you had a cleaner way to do it! I didn't know if there was some kind of trigger that could be attached to connectors and even if there was, I didn't know whether a plugin would be able to wire itself up across the separate jar...my java is very, very rusty.

      Thanks.

      P.S. Your dad says hi.

      Comment


      • #4
        The updateStatus method doesn't have anything to do with the client, that is the server-side trigger you're looking for. The connectors themselves invoke it directly; here's an example from MllpMessageDispatcher:

        Code:
        private void writeTemplatedData(Socket socket, MessageObject data) throws Exception {
                monitoringController.[B]updateStatus[/B](connector, connectorType, Event.BUSY, socket);
                if (!connector.getTemplate().equals("")) {
                    String template = replacer.replaceValues(connector.getTemplate(), data);
                    write(socket, template);
                } else {
                    write(socket, data.getEncodedData());
                }
                monitoringController.[B]updateStatus[/B](connector, connectorType, Event.[B]DONE[/B], socket);
            }
        So the server-side ConnectorStatusPlugin would be updating correctly regardless of what any clients are doing. When the client does a dashboard refresh, it tells each column plugin "I'm refreshing the statuses" (the tableUpdate method). In your case, you would want to use that tableUpdate method to grab data from your server plugin. So it doesn't matter how often or when a client decides to refresh... when it finally does refresh, it will still get the correct data from the server.

        Anyway, I whipped up a quick example (this is for 2.2.2) and attached it. Just open up an instance of 2.2.2, go to the Extensions view, install the sent-time-2.2.2.zip archive, restart the server, and it should be good to go.

        Let me know if I'm misunderstanding what you're trying to accomplish!
        Attached Files
        Last edited by narupley; 01-24-2014, 07:04 AM.
        Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

        Nicholas Rupley
        Work: 949-237-6069
        Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


        - How do I foo?
        - You just bar.

        Comment

        Working...
        X