Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-2237

Improper ordering of MINA filters

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.0
    • 2.2.0
    • camel-mina
    • None
    • Patch Available

    Description

      When we want to use SSL on the consumer side, MINA's SSLFilter must be inserted as the very first filter into the chain (or, at least, as the second one after an ExecutorFilter), but it is currently not possible, because MinaComponent#createSocketEndpoint() always inserts a ProtocolCodecFilter at the very beginning by calling configureCodecFactory().

      A proposed workaround is to introduce an additional URL parameter noDefaultCodec which prohibits the installation of the default protocol codec filter. The protocol codec must be then configured manually, e.g. using Spring:

      <bean id="sslFilter" class="org.apache.mina.filter.SSLFilter">
      <constructor-arg>
      <bean class="javax.net.ssl.SSLContext" factory-method="getDefault" />
      </constructor-arg>
      </bean>

      <bean id="codecFilter" class="org.apache.mina.filter.codec.ProtocolCodecFilter">
      <constructor-arg ref="hl7codec" />
      </bean>

      <bean id="hl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec" />

      <bean id="minaFilters" class="java.util.ArrayList">
      <constructor-arg>
      <list value-type="org.apache.mina.common.IoFilter">
      <ref bean="sslFilter" />
      <ref bean="codecFilter" />
      </list>
      </constructor-arg>
      </bean>

      After that, the consumer endpoint URL can look like
      from("mina:tcp://0.0.0.0:8888?sync=true&lazySessionCreation=true&noDefaultCodec=true&filters=#minaFilters").

      I am not sure whether this approach is optimal, therefore I call it "workaround" and not "solution". The corresponding patch is attached.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            mrt1nz Martin Krasser
            rnd Dmytro Rud
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment