Qpid
  1. Qpid
  2. QPID-2519

Allow Windows Broker to run as a Service

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.14
    • Component/s: C++ Broker
    • Labels:
      None
    • Environment:

      Windows

      Description

      The Windows version of the C++ Broker should have the ability to run as a Windows Service, to correspond with the ability of the *nix version to run as a daemon, as this is a common requirement for critical software infrastructure elements of enterprise class software on the Windows platform.

      1. QPID-2519.diff
        26 kB
        Steve Huston
      2. broker_as_service_r921371.patch
        41 kB
        Kerry Bonin
      3. broker_as_service_Qpid_Logging.patch
        45 kB
        Daniel Sack

        Activity

        Hide
        Kerry Bonin added a comment - - edited

        This patch implements most of my worklist for the feature.

        • No changes to cross-platform qpidd.cpp
        • Preserve single executable.
        • Preserve service encapsulation in separate class (WinService)
        • Encapsulate basic SCM features via command line - install, start, stop, uninstall
        • Allow basic SCM options at install - account, dependent service list
        • Runs on XP through Win7, Server 2003 & 2008 (passed a few weeks system test)

        Features I still want and plan to add, but can't get to right now, hope to get back to soon...

        • Rename service
        • Set service description text
        • Change default account name
        • Change startup error level
        • Clean up event log use for error reporting - add & use message files for proper formatting.

        Please let me know if anyone has any issues or concerns with these changes, and I'll do my best to fix them ASAP. We've already built this into a major product release, its worked well in test so far...

        Kerry Bonin

        Show
        Kerry Bonin added a comment - - edited This patch implements most of my worklist for the feature. No changes to cross-platform qpidd.cpp Preserve single executable. Preserve service encapsulation in separate class (WinService) Encapsulate basic SCM features via command line - install, start, stop, uninstall Allow basic SCM options at install - account, dependent service list Runs on XP through Win7, Server 2003 & 2008 (passed a few weeks system test) Features I still want and plan to add, but can't get to right now, hope to get back to soon... Rename service Set service description text Change default account name Change startup error level Clean up event log use for error reporting - add & use message files for proper formatting. Please let me know if anyone has any issues or concerns with these changes, and I'll do my best to fix them ASAP. We've already built this into a major product release, its worked well in test so far... Kerry Bonin
        Hide
        Steve Huston added a comment -

        I reviewed the patch quickly and have a few requests:

        1. Please reformat according to Qpid coding style (http://qpid.apache.org/qpid-c-documentation.html) - no tabs, consistent brace style
        2. There's a global WinService in QpiddBroker.cpp - what's that for?
        3. Lots of printfs and no Qpid logging statements, and no exception throwing on error. Please review these and probably should be throwing on errors; outputs should probably be using logging to be redirected as the user specified.

        Show
        Steve Huston added a comment - I reviewed the patch quickly and have a few requests: 1. Please reformat according to Qpid coding style ( http://qpid.apache.org/qpid-c-documentation.html ) - no tabs, consistent brace style 2. There's a global WinService in QpiddBroker.cpp - what's that for? 3. Lots of printfs and no Qpid logging statements, and no exception throwing on error. Please review these and probably should be throwing on errors; outputs should probably be using logging to be redirected as the user specified.
        Hide
        Daniel Sack added a comment -

        Hi,
        Scince we need this patch for our production system, I tried to implement parts of the comments
        1. Please reformat according to Qpid coding style (http://qpid.apache.org/qpid-c-documentation.html) - no tabs, consistent brace style
        -> didn't have the time for it

        2. There's a global WinService in QpiddBroker.cpp - what's that for?
        -> Responsible for all the daemon stuff which is needed for the windows platform.

        3. Lots of printfs and no Qpid logging statements, and no exception throwing on error. Please review these and probably should be throwing on errors; outputs should probably be using logging to be redirected as the user specified.
        -> triedto fix this

        Show
        Daniel Sack added a comment - Hi, Scince we need this patch for our production system, I tried to implement parts of the comments 1. Please reformat according to Qpid coding style ( http://qpid.apache.org/qpid-c-documentation.html ) - no tabs, consistent brace style -> didn't have the time for it 2. There's a global WinService in QpiddBroker.cpp - what's that for? -> Responsible for all the daemon stuff which is needed for the windows platform. 3. Lots of printfs and no Qpid logging statements, and no exception throwing on error. Please review these and probably should be throwing on errors; outputs should probably be using logging to be redirected as the user specified. -> triedto fix this
        Hide
        Steve Huston added a comment -

        Assigning this to me, but it's as time permits. If anyone has interest/time in moving this along quicker, please let me know and we'll coordinate a hand-off.

        Show
        Steve Huston added a comment - Assigning this to me, but it's as time permits. If anyone has interest/time in moving this along quicker, please let me know and we'll coordinate a hand-off.
        Hide
        Steve Huston added a comment -

        FYI, I branched qpid/trunk/qpid to branches/QPID-2519 to work on this.

        Show
        Steve Huston added a comment - FYI, I branched qpid/trunk/qpid to branches/ QPID-2519 to work on this.
        Hide
        Kerry Bonin added a comment -

        I should have time this week to (finally) help finish this...

        Show
        Kerry Bonin added a comment - I should have time this week to (finally) help finish this...
        Hide
        Steve Huston added a comment -

        Kerry, what kind of time do you have, and what were you planning to work on? I started with the most recent attached patch and have started hacking on it, mostly doing what I originally asked for and Daniel Sack said he didn't have time for (make code conform to Qpid guidelines, mostly) and have been noting things that are obvious to be addressed but will then look more closely at the code and what it's doing. If you plan to work on the code, I'll be more proactive about checking into the branch.

        Show
        Steve Huston added a comment - Kerry, what kind of time do you have, and what were you planning to work on? I started with the most recent attached patch and have started hacking on it, mostly doing what I originally asked for and Daniel Sack said he didn't have time for (make code conform to Qpid guidelines, mostly) and have been noting things that are obvious to be addressed but will then look more closely at the code and what it's doing. If you plan to work on the code, I'll be more proactive about checking into the branch.
        Hide
        Kerry Bonin added a comment -

        Hello Steve!

        I checked out the branch yesterday and noticed it didn't contain any any of
        the work, I was going to rebuild the tree today with my original and
        Daniel's patches. I was going to attempt to find a decent code formatter
        and setup a Qpid template (my dev environment is already configured for the
        coding style of the other projects I work on), and look at fixing any
        remaining logging. When I delivered the original code I converted its
        logging calls to printfs, I hadn't seen the QPID logger used yet, figured it
        would be simple to convert.

        I'm not aware of other code changes required. FWIW, that code has been
        through three projects and a significant degree of system and integration
        testing, and we're using it as one of our core Windows services. Used to be
        GE Security, we were bought out and are now UTC Fire & Security, I'm still
        the Systems Architect, and we've now convinced UTC F&S that we were merged
        into to use AMQP/QPID for messaging and as the ESB foundation. UTC will be
        shipping that service (my original patch applied to trunk code) shortly
        too. These are big products its used in - Picture Perfect, FCWnx and
        OnGuard are enterprise class access control systems (think multinational
        firms, airports, subways), and the new projects in Fire and Video are major
        as well.

        I wrote the WindowsService wrapper, if you have any questions about it feel
        free to ask. Its a relatively simple port of the MSDN service example
        reference code into a single C++ class to simplify integration with existing
        code, I've used it to make services out of a number of libraries over the
        years.

        If you've started the conversion, let me know if you want me to pick up and
        finish it, I should have a few days this week free, and a few days next
        week.

        Sorry about leaving this hanging, we didn't expect the acquisition, and it
        ate a year. I'll be working on QPID projects for most of the rest of the
        year here, bring up an ESB over something like QMFv2, and trying to help
        make Windows failover & federation work better (or at all.)

        Kerry

        Show
        Kerry Bonin added a comment - Hello Steve! I checked out the branch yesterday and noticed it didn't contain any any of the work, I was going to rebuild the tree today with my original and Daniel's patches. I was going to attempt to find a decent code formatter and setup a Qpid template (my dev environment is already configured for the coding style of the other projects I work on), and look at fixing any remaining logging. When I delivered the original code I converted its logging calls to printfs, I hadn't seen the QPID logger used yet, figured it would be simple to convert. I'm not aware of other code changes required. FWIW, that code has been through three projects and a significant degree of system and integration testing, and we're using it as one of our core Windows services. Used to be GE Security, we were bought out and are now UTC Fire & Security, I'm still the Systems Architect, and we've now convinced UTC F&S that we were merged into to use AMQP/QPID for messaging and as the ESB foundation. UTC will be shipping that service (my original patch applied to trunk code) shortly too. These are big products its used in - Picture Perfect, FCWnx and OnGuard are enterprise class access control systems (think multinational firms, airports, subways), and the new projects in Fire and Video are major as well. I wrote the WindowsService wrapper, if you have any questions about it feel free to ask. Its a relatively simple port of the MSDN service example reference code into a single C++ class to simplify integration with existing code, I've used it to make services out of a number of libraries over the years. If you've started the conversion, let me know if you want me to pick up and finish it, I should have a few days this week free, and a few days next week. Sorry about leaving this hanging, we didn't expect the acquisition, and it ate a year. I'll be working on QPID projects for most of the rest of the year here, bring up an ESB over something like QMFv2, and trying to help make Windows failover & federation work better (or at all.) Kerry
        Hide
        Steve Huston added a comment -

        I checked in the applied-and-formatted code from the patch for your use.
        I have begun to look at the code in more depth and will be proposing changes to it, and also Andrew Stitcher suggested I put this up on the Qpid reviewer site for wider review. I will do that after working on changes such as:

        • Separating the SCM-supporting code from the service-run-time code
        • Changing the way command line and service entry is handled
        • Make a service-started broker default to logging to Windows logger, and removing the specific logger code from the new Service code
        • Some structural changes, probably - there's a lot of duplicate code
        Show
        Steve Huston added a comment - I checked in the applied-and-formatted code from the patch for your use. I have begun to look at the code in more depth and will be proposing changes to it, and also Andrew Stitcher suggested I put this up on the Qpid reviewer site for wider review. I will do that after working on changes such as: Separating the SCM-supporting code from the service-run-time code Changing the way command line and service entry is handled Make a service-started broker default to logging to Windows logger, and removing the specific logger code from the new Service code Some structural changes, probably - there's a lot of duplicate code
        Hide
        Kerry Bonin added a comment -

        There is a good deal of duplicated and strangely flowing code there - as I
        said I basically just took the MSDN sample service code and converted it
        into a class. For me there was never a justification to clean it up
        further, as it was such special case code.

        Show
        Kerry Bonin added a comment - There is a good deal of duplicated and strangely flowing code there - as I said I basically just took the MSDN sample service code and converted it into a class. For me there was never a justification to clean it up further, as it was such special case code.
        Hide
        Steve Huston added a comment -

        Patch against the point the trunk was branched; would replace orignal patch. I'll add this to the review site as well.

        Show
        Steve Huston added a comment - Patch against the point the trunk was branched; would replace orignal patch. I'll add this to the review site as well.
        Hide
        Steve Huston added a comment -

        Fixed; patches on trunk at r1187499

        Show
        Steve Huston added a comment - Fixed; patches on trunk at r1187499

          People

          • Assignee:
            Steve Huston
            Reporter:
            Kerry Bonin
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development