Thank you Tim for the affirmation, 

Apache Camel, at least, touts that you can tie in so many technologies for just 
about any connection technology, any payload, and transform to another, all by 
utilizing the massive collection of work done by others, instead of hand coding 
it yourself. Feeling like I hit a brick wall when it came to "plugging in" one 
Apache product to another, I began to question my technological skills; like I 
must be missing some big concept.  

I don't mean to start a Camel complaint thread, where I whine and carry on.. I 
am still pushing the idea ahead here... that I'm still at a stoppage of further 
progress; that I cannot seem to either start again and redevelop under a 
vanilla Karaf acceptable project.. or port this Java DSL into something that 
can be called from something that runs under Karaf.

If I am to reference a "bean" within a  Blueprint archetype, and my "bean" is 
what is instantiating a Camel context.. Can I simply use a non-camel maven 
blueprint archetype, since the camel-blueprint one is giving me trouble?  I've 
googled all the responses here and attempted what I thought I could do.. but 
one slight off topic thread said it might be my java version?  I did start this 
project with the most current Java to begin, so it would be a bit before it got 
behind, and used Java 10.  Perhaps that is too new to play nice with others?

It's been a bit on this thread since I included my code, so I will send it 
again.
Thanks all!


On ‎Thursday‎, ‎October‎ ‎18‎, ‎2018‎ ‎04‎:‎17‎:‎37‎ ‎AM‎ ‎EDT, Tim Ward 
<tim.w...@paremus.com> wrote: 





This is an argument that I hear a lot. I’m not a Camel expert, but it really 
sounds as though the DSL needs some work. The whole point of a DSL is that by 
being domain specific it is supposed to be natural and easy. Instead it sounds 
as though it is forcing people into using Blueprint despite that being a “less 
preferred” option for some people.

Given the level of Camel integration in Karaf/Blueprint there must be someone 
in the community with the relevant skills to overhaul the DSL and make it fit 
for purpose?

Best Regards,

Tim

> On 17 Oct 2018, at 23:46, John F. Berry <bohnje...@yahoo.com> wrote:
> 
> 
> 
> Thank you.. I was thinking of abandoning the Java DSL and ultimately going 
> this way, given my lack of success of "dumping it" into an OSGi container of 
> some sort.  The rest of my shop, though, are not blueprint DSL, Camel or 
> Apache product savvy, so the learning curve for my coworkers will be more 
> disconnected than tapping into their java knowledge.
> I was attempting, originally, to introduce Camel as a solution via Java DSL 
> to encourage its adoption. 
> 
> 
>  
>  
>  On Wednesday, October 17, 2018, 3:50:58 PM EDT, Jean-Baptiste Onofré 
><j...@nanthrax.net> wrote: 
> 
> 
> 
> 
> 
> You can also directly use the Camel Blueprint DSL directly, just putting 
> your route in OSGI-INF/blueprint/route.xml:
> 
> <blueprint>
>     <camelContext xmlns="http://camel.apache.org/schema/blueprint";>
>         <route id="foo">
>             <from uri="..."/>
>             ...
>             <to uri="..."/>
>         </route>
>     </camelContext>
> </blueprint>
> 
> Regards
> JB
> 
> On 17/10/2018 21:46, Ranx wrote:
>> 
>> You'll want to use the bundle plugin and create a blueprint.xml to bootstrap
>> your Camel Java DSL. I use the Camel Java DSL all the time in Blueprint for
>> a variety of reasons (testing is easier as the RouteBuilders exist without
>> the camel context). I’m not sure why your Camel blueprint archetype is
>> blowing up but I’d start with that first but then you’ll have to modify the
>> blueprint file to add your
>> 
>> Here's a snippet:
>> 
>> 
>> <bean class="foo.bar.MyFirstRouteBuilder" id="firstRouteBuilder"/>
>> <bean class="foo.bar.MySecondRouteBuilder" id="secondRouteBuilder"/>
>> 
>>      
>>      <camelContext
>> id="document-logic-service"xmlns="http://camel.apache.org/schema/blueprint";>
>>          <routeBuilder ref="firstRouteBuilder"/>
>>          <routeBuilder ref="secondRouteBuilder"/>
>>      </camelContext>
>> 
>> The RouteBuilders can be independently unit tested then with
>> CamelTestSupport outside the Blueprint container.
>> 
>> This also allows an injection and setup to take place for your route
>> builders when they are instantiated and then when the Camel context is given
>> their reference. Without that step Camel and Felix/Karaf are unaware of
>> their existence.
>> 
>> If you can’t get the archetype to run and create a Camel Blueprint project
>> for you, I’d Google around for a sample project that has the POM correct.
>> 
>> Generally I'll have a features file and configuration file associated with
>> the project as well so that the features repository can be added and
>> installed. There may be a better way to do this with profiles in Karaf 4 but
>> I'm a bit behind the times in that regard.
>> 
>> Ranx
>> 
>> 
>> 
>> 
>> --
>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>> 
> 
> 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>

  <modelVersion>4.0.0</modelVersion>

  <groupId>org.somecompany.camel</groupId>
  <artifactId>EDMtoPSoft-java</artifactId>
  <packaging>bundle</packaging>
  <version>1.0.0</version>

  <name>EDM base64 HL7 documents to PeopleSoft</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>

  <dependencyManagement>
    <dependencies>
      <!-- Camel BOM -->
      <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-parent</artifactId>
        <version>2.22.1</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-blueprint</artifactId>
    </dependency>

    <!-- logging -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <scope>runtime</scope>
    </dependency>

    <!-- testing -->
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-test</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
     <groupId>javax.xml.bind</groupId>
     <artifactId>jaxb-api</artifactId>
     <version>2.2.11</version>
    </dependency>
    <dependency>
     <groupId>javax.activation</groupId>
     <artifactId>activation</artifactId>
     <version>1.1.1</version>
    </dependency>
    <dependency>
     <groupId>org.apache.camel</groupId>
     <artifactId>camel-mllp</artifactId>
     <version>2.21.1</version>
    </dependency>

    <!-- Project stuff -->
    <dependency>
     <groupId>org.apache.camel</groupId>
     <artifactId>camel-hl7</artifactId>
     <version>2.21.1</version>
    </dependency>

    <dependency>
     <groupId>org.apache.camel</groupId>
     <artifactId>camel-netty4</artifactId>
     <version>2.21.1</version>
    </dependency>

    <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-base64</artifactId>
    <version>2.21.1</version>
    </dependency>

    <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-sql</artifactId>
    <version>2.21.1</version>
    </dependency>
    
    <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-dbcp2</artifactId>
    <version>2.5.0</version>
    </dependency>

    <dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>7.0.0.jre10</version>
    </dependency>


  </dependencies>

  <build>
    <defaultGoal>install</defaultGoal>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.0.2</version>
        <configuration>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>

      <!-- Allows the example to be run via 'mvn compile exec:java' -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <configuration>
          <mainClass>org.somecompany.camel.MainApp</mainClass>
          <includePluginDependencies>false</includePluginDependencies>
        </configuration>
      </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>org.somecompany.camel.MainApp</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>

                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>


<!-- to generate the MANIFEST.MF of the bundle -->
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>3.5.0</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>bundle-manifest</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>manifest</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- to include MANIFEST.MF in the bundle -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.0.2</version>
        <configuration>
          <archive>
            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
      </plugin>


    </plugins>
  </build>

</project>
package org.somecompany.camel;

import org.apache.camel.main.Main;

/**
 * A Camel Application
 */
public class MainApp {

    /**
     * A main() so we can easily run these routing rules in our IDE
     */
    public static void main(String... args) throws Exception {
        Main main = new Main();
        main.addRouteBuilder(new MyRouteBuilder());
        main.run(args);
    }
}


package org.somecompany.camel;


import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import ca.uhn.hl7v2.model.Message;
import org.apache.camel.builder.RouteBuilder;
import ca.uhn.hl7v2.util.Terser;
import ca.uhn.hl7v2.DefaultHapiContext;
import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.HapiContext;
import java.util.Base64;
import org.apache.camel.spi.DataFormat;


import ca.uhn.hl7v2.parser.Parser;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.camel.component.sql.SqlComponent;

public class MyRouteBuilder extends RouteBuilder {
    @Override
    public void configure() throws Exception {
                 BasicDataSource basicDataSource = new BasicDataSource();
                 
basicDataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                 
basicDataSource.setUrl("jdbc:sqlserver://INFPRDDB:52739;databaseName=MGH_Work;");
                 basicDataSource.setUsername("username");
                 basicDataSource.setPassword("password");
                 SqlComponent sqlComponent = new SqlComponent();
                 sqlComponent.setDataSource(basicDataSource);
                 getContext().addComponent("psoft-sql", sqlComponent);


        from("mllp://0.0.0.0:8888")
        .log("..Received HL7 message with control id 
${header.CamelMllpMessageControlId}")
        .convertBodyTo(String.class)
        .unmarshal()
        .hl7(false)
        .process(new Processor() {
          public void process(Exchange exchange) throws Exception {
          Message message = exchange.getIn().getBody(Message.class);
          ca.uhn.hl7v2.util.Terser terser = new Terser(message);
          String obx5 = terser.get("/.OBX-5-5");
          String EDMId = terser.get("/.OBR-3") + ".pdf";
          String voucher = terser.get("/.OBR-2");

          byte[] decoded = Base64.getDecoder().decode(obx5);
          exchange.getOut().setBody(decoded);
          exchange.getOut().setHeader("voucher", voucher);
          exchange.getOut().setHeader("CamelFileName", EDMId );
            }
          } )
       .log("..Processed voucher ${header.voucher} to file 
${header.CamelFileName}")
       .to("file:target/messages/others")
       .recipientList(simple("psoft-sql:INSERT INTO lawsonprod.PeopleSoftVCR 
(Voucher, Facility, image) VALUES ('12345', '1', '${header.CamelFileName}')") )
       ;

    }

}

Reply via email to