configure continuation timeout in jboss fuse esb - apache-camel

I am using jboss fuse esb 6.2.0. I would like change the jetty continuation timeout at server level(i.e single configuration for all apis continuation timeout), can any one help me to do this. I tried a lot at the end I found setting at http endpoint level like one explained in configure-timeout-for-apache-camel-jetty-component.
Please find the jetty.xml configuration
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host">
<Property name="jetty.host"/>
</Set>
<!-- We explicitly set port to 0 to avoid port conflicts, then a real port will be picked
from org.ops4j.pax.web pid, which is PortService aware
-->
<Set name="port">
<Property name="jetty.port" default="0"/>
</Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.plus.jaas.JAASLoginService">
<Set name="name">karaf</Set>
<Set name="loginModuleName">karaf</Set>
<Set name="roleClassNames">
<Array type="java.lang.String">
<Item>org.apache.karaf.jaas.boot.principal.RolePrincipal</Item>
</Array>
</Set>
</New>
</Arg>
</Call>

Related

How can I get a key_value from a specific mapped_value in AIML?

I'm starting to learn some AIML and I'm quite lost at this point.
I'm working with maps but I can't think of an algorithm to solve this problem.
Let's say I have a map in which I'm storing my friends' hair color. Something like Markus:brown.
Now let's say I want to get all the names whose hair color is brown. Something like:
Human: Could you tell me the names of my friends whose hair color is brown?
Robot: Markus Kevin Thomas
Edit: Doing some research I found that many users create a the oposite map, I mean, person:hair, hair:person. But if I have different people with the same color, would the map return the first one? How could I get all of them?
How could I do that?
Thanks in advance.
You can't really do this using maps unless you set up a map like this:
[
["brown", "Markus, David, Thomas"],
["black", "Stephen, Paul"],
["blonde", "Simon"]
]
This could be a lot of manual work and not really practical. When I work with simple databases like this, I set up each entry in its own category:
<category>
<pattern>XFRIEND 1</pattern>
<template>
<think>
<set name="friend">Markus</set>
<set name="hair">brown</set>
<set name="eyes">blue</set>
<set name="likes">pizza</set>
</think>
</template>
</category>
<category>
<pattern>XFRIEND 2</pattern>
<template>
<think>
<set name="friend">Kevin</set>
<set name="hair">black</set>
<set name="eyes">brown</set>
<set name="likes">burgers</set>
</think>
</template>
</category>
<category>
<pattern>XFRIEND 3</pattern>
<template>
<think>
<set name="friend">Thomas</set>
<set name="hair">brown</set>
<set name="eyes">green</set>
<set name="likes">burgers</set>
</think>
</template>
</category>
<category>
<pattern>XFRIEND 4</pattern>
<template>
<think>
<set name="friend">David</set>
<set name="hair">black</set>
<set name="eyes">blue</set>
<set name="likes">burgers</set>
</think>
</template>
</category>
And then create a category which will scan and check each entry:
<category>
<pattern>XSCANFRIENDSDATABASE</pattern>
<template>
<think>
<set name="list">Results:<br/></set>
<srai>XFRIEND 1</srai>
<srai>XCHECKMATCH</srai>
<srai>XFRIEND 2</srai>
<srai>XCHECKMATCH</srai>
<srai>XFRIEND 3</srai>
<srai>XCHECKMATCH</srai>
<srai>XFRIEND 4</srai>
<srai>XCHECKMATCH</srai>
</think>
<get name="list"/>
</template>
</category>
Now we have our database set up, let's see how we can use it. I want to know, "Who has (whatever coloured) hair". We can do this with this category:
<category>
<pattern>WHO HAS * HAIR</pattern>
<template>
<think>
<set name="searchfor"><star/></set>
<learn>
<category>
<pattern>XCHECKMATCH</pattern>
<template>
<condition name="hair">
<li><value><get name="searchfor"/></value>
<set name="list"><get name="list"/><br/><get name="friend"/></set>
</li>
</condition>
</template>
</category>
</learn>
</think>
<srai>XSCANFRIENDSDATABASE</srai>
</template>
</category>
So in your query, "Who has brown hair", the predicate "searchfor" is set to "brown", as that is what we are searching for.
We then use the <learn> tag to set up a temporary category called "XCHECKMATCH" which looks at the value of "hair" in each of the entries in our database and compares it to "searchfor". If it matches, add it to the list.
Once set up, we scan the database and display the results.
Human - Who has brown hair?
Bot - Results:
Markus
Thomas
As an advanced use of this, we can also check for more than one item. For example, "Who has black hair and likes burgers?"
<category>
<pattern>WHO HAS * HAIR AND LIKES *</pattern>
<template>
<think>
<set name="searchfor"><star/> <star index="2"/></set>
<learn>
<category>
<pattern>XCHECKMATCH</pattern>
<template>
<think><set name="found"><get name="hair"/> <get name="likes"/></set></think>
<condition name="found">
<li><value><get name="searchfor"/></value>
<set name="list"><get name="list"/><br/><get name="friend"/></set>
</li>
</condition>
</template>
</category>
</learn>
</think>
<srai>XSCANFRIENDSDATABASE</srai>
</template>
</category>
In this example, "searchfor" becomes "black burgers". We set up a new predicate called "found" (what the database has found). This is made up of "<get name="hair"/> <get name="likes"/>" and once again we scan the database to see what matches:
Human - "Who has black hair and likes burgers?"
Bot - Results: Kevin
David
I use this database method regularly for answering crazy questions like "Is a train faster than a snail?". There's no point in creating categories for this one example and so a database method is far more useful and easier to maintain.
If this is beyond the level of what you are needing, you will need to use a map and a category like this:
[
["brown", "Markus, David, Thomas"],
["black", "Stephen, Paul"],
["blonde", "Simon"]
]
<category>
<pattern>WHO HAS * HAIR</pattern>
<template>
<map name="hair"><star/></map>
</template>
</category>
However, this has nowhere near the flexibility of using a database style structure.
Human - Who has brown hair?
Bot - Markus, David, Thomas
If you are planning on doing that though, you might as well just do:
<category>
<pattern>WHO HAS BROWN HAIR</pattern>
<template>
Markus, David, Thomas.
</template>
</category>
Hope that makes sense. Happy to clarify anything if you need me to.

WSo2 Esb filtering messages to an output file Part 2

Ok, this is a continuation to my original question. (WSo2 Esb filtering messages to an output file)
After a couple more days of research into the iterate and aggregate mediator I have reached a progress wall and would be very grateful for any advice how to resolve my blocking issue. The task at hand is simple, read and xml file, filter on certain records, and only produce an output xml file with just those records that meet the criteria. After previous discussion and research this tasks solution is as follows: use a iterate mediator to access each xml record and use a filter mediator to decide what I want to keep. Then use a aggregator mediator to write all these records to 1 file. Without the aggregator my configuration is producing 1 record per file.
Here is my proxy at this state:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="RenFileFilterProxy"
transports="vfs"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<clone>
<target sequence="RenIqtFilterSequence"/>
</clone>
</inSequence>
<outSequence>
<log level="custom">
<property name="sequence" value="In the outSequence"/>
</log>
<log level="full"/>
<aggregate id="QuizType">
<completeCondition>
<messageCount min="-1" max="-1"/>
</completeCondition>
<onComplete xmlns:z="RowsetSchema" expression="//z:row">
<call-template target="FileWriteTemplate">
<with-param name="targetFileName" value="TEST_FILE"/>
<with-param name="addressUri" value="vfs:file:///var/process/ren/rrout"/>
</call-template>
</onComplete>
</aggregate>
</outSequence>
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">15</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///var/process/ren/extractedfiles</parameter>
<parameter name="transport.vfs.FileURI">file:///var/process/ren/extractedfiles</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///var/process/ren/failure</parameter>
<parameter name="transport.vfs.FileNamePattern">test.xml</parameter>
<parameter name="transport.vfs.ContentType">application/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<description/>
</proxy>
Here is the RenIqtFilterSequence:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="RenIqtFilterSequence">
<log level="custom">
<property name="sequence" value="RenIqtFilterSequence"></property>
</log>
<iterate xmlns:ns2="http://org.apache.synapse/xsd" xmlns:ns="http://org.apache.synapse/xsd" xmlns:z="RowsetSchema" expression="//z:row" id="QuizType">
<target>
<sequence>
<log>
<property name="iteratesequence" value="Iterating through the the records"></property>
</log>
<filter xmlns:rs="urn:schemas-microsoft-com:rowset" xpath="//z:row/#name='RP'">
<then>
<log level="custom">
<property name="sequence" value="Condition Write"></property>
</log>
<log level="full"></log>
<log level="custom">
<property name="sequence" value="Getting ready to aggregate"></property>
</log>
</then>
<else>
<log level="custom">
<property name="sequence" value="Condition Drop"></property>
</log>
<drop></drop>
</else>
</filter>
</sequence>
</target>
</iterate>
</sequence>
The issue I am facing now is I cannot get to the outSequence to perform my aggregator logic. The fact is I do not need to call a backend service for this process from the inSequence so I am struggling to find a clean way to get to my outSequence. Any Recomendations? I tried to include the aggregator mediator in my inSequence but it did not work, no output is produced. I figured the aggregator needs to be in the outSequence to capture all the records I filtered and then I can write them all out to 1 file.
I believe I need some configuration here:
<filter xmlns:rs="urn:schemas-microsoft-com:rowset" xpath="//z:row/#name='RP'">
<then>
<log level="custom">
<property name="sequence" value="Condition Write"></property>
</log>
<log level="full"></log>
<log level="custom">
<property name="sequence" value="Getting ready to aggregate"></property>
</log>
===============> Need to transfer to OutSequence somehow here!!!!<============
</then>
<else>
I have tried several approaches based on articles and blogs online but I just cannot put the final pieces in place. Any advice would be much appreciated. Thank you for your time reading this.

gzip compression not working in Solr 5.1

I'm trying to apply gzip compression in Solr 5.1. I understand that Running Solr on Tomcat is no longer supported from Solr 5.0, so I've tried to implement it in Solr.
I've downloaded jetty-servlets-9.3.0.RC0.jar and placed it in my webapp\WEB-INF folder, and have added the following in webapp\WEB-INF\web.xml:
<filter>
<filter-name>GzipFilter</filter-name>
<filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
<init-param>
<param-name>methods</param-name>
<param-value>GET,POST</param-value>
<param-name>mimeTypes</param-name>
<param-value>text/html,text/plain,text/xml,text/json,text/javascript,text/css,application/xhtml+xml,application/javascript,image/svg+xml,application/json,application/xml; charset=UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>GzipFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
However, when I start Solr and check the browser, there's no gzip compression, and I only get the following at the Response Headers output:
Content-Type:text/plain;charset=UTF-8
Transfer-Encoding:chunked
Is there anything which I configure wrongly or might have missed out? I'm also running zookeeper-3.4.6.
Download a kosher version of Jetty that closely matches what is currently in Solr: http://www.eclipse.org/jetty/download.html
Extract that .zip to a location you will discard.
Copy out these files to your copy of jetty in Solr (located in path-to-solr/server/):
modules/gzip.mod
etc/gzip.xml
Modify modules/gzip.mod:
#
# GZIP module
# Applies GzipHandler to entire server
#
[depend]
server
[xml]
etc/jetty-gzip.xml
[ini-template]
## Minimum content length after which gzip is enabled
jetty.gzip.minGzipSize=2048
## Check whether a file with *.gz extension exists
jetty.gzip.checkGzExists=false
## Gzip compression level (-1 for default)
jetty.gzip.compressionLevel=-1
## User agents for which gzip is disabled
jetty.gzip.excludedUserAgent=.*MSIE.6\.0.*
Modify etc/gzip.xml:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<!-- =============================================================== -->
<!-- Mixin the GZIP Handler -->
<!-- This applies the GZIP Handler to the entire server -->
<!-- If a GZIP handler is required for an individual context, then -->
<!-- use a context XML (see test.xml example in distribution) -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="insertHandler">
<Arg>
<New id="GzipHandler" class="org.eclipse.jetty.server.handler.gzip.GzipHandler">
<Set name="minGzipSize">
<Property name="jetty.gzip.minGzipSize" deprecated="gzip.minGzipSize" default="2048"/>
</Set>
<Set name="checkGzExists">
<Property name="jetty.gzip.checkGzExists" deprecated="gzip.checkGzExists" default="false"/>
</Set>
<Set name="compressionLevel">
<Property name="jetty.gzip.compressionLevel" deprecated="gzip.compressionLevel" default="-1"/>
</Set>
<Set name="excludedAgentPatterns">
<Array type="String">
<Item>
<Property name="jetty.gzip.excludedUserAgent" deprecated="gzip.excludedUserAgent" default=".*MSIE.6\.0.*"/>
</Item>
</Array>
</Set>
<Set name="includedMethods">
<Array type="String">
<Item>GET</Item>
<Item>POST</Item>
</Array>
</Set>
<Set name="includedPaths"><Array type="String"><Item>/*</Item></Array></Set>
<Set name="excludedPaths"><Array type="String"><Item>*.gz</Item></Array></Set>
<Call name="addIncludedMimeTypes"><Arg><Array type="String">
<Item>text/html</Item>
<Item>text/plain</Item>
<Item>text/xml</Item>
<Item>application/xml</Item><!-- IMPORTANT - DO NOT FORGET THIS LINE -->
<Item>application/xhtml+xml</Item>
<Item>text/css</Item>
<Item>application/javascript</Item>
<Item>image/svg+xml</Item>
</Array></Arg></Call>
<!--
<Call name="addExcludedMimeTypes"><Arg><Array type="String"><Item>some/type</Item></Array></Arg></Call>
-->
</New>
</Arg>
</Call>
</Configure>
Here's the part that should make you cringe a bit.
Modify bin\solr.cmd
...
set "SOLR_JETTY_CONFIG=--module=http,gzip"
...
set "SOLR_JETTY_CONFIG=--module=https,gzip"
...
Notice that --module=http was already there. Just add ",gzip" so it matches the lines above.
I would prefer finding a better way of specifying the gzip module to load, but I don't know how. If you know how, please reply to this answer and tell me how because I hate modifying a script that comes with a product--it's a maintenance nightmare and, well, I think you get the picture.
After this, restart the solr server and gzip should now be enabled--at least for &wt=xml, which is sent back as Content-Type: application/xml.
You can add what you need to the etc/gzip.xml and restart the solr server for it to recognize your changes.
I tested with and without compression of 1000 documents. For me, it was the difference between 3.8 MB and 637 KB.

Cannot set WrapTypes using wlconfig for JDBCConnectionPool

I created JDBC connection pool using ant script.
<target name="create-cmifs-connpool">
<wlconfig username="${user}" password="${password}" url="${wls.url}">
<query domain="${domain.name}" type="Server" name="${servername}" property="x" />
<create type="JDBCConnectionPool" name="cmifsDBPool">
<set attribute="CapacityIncrement" value="1"/>
<set attribute="DriverName" value="oracle.jdbc.OracleDriver"/>
<set attribute="InitialCapacity" value="1"/>
<set attribute="MaxCapacity" value="10"/>
<set attribute="Password" value="${env.DB_PWD}"/>
<set attribute="Properties" value="user=${env.DB_USER}"/>
<set attribute="RefreshMinutes" value="0"/>
<set attribute="ShrinkPeriodMinutes" value="15"/>
<set attribute="ShrinkingEnabled" value="true"/>
<set attribute="TestConnectionsOnRelease" value="false"/>
<set attribute="TestConnectionsOnReserve" value="false"/>
<set attribute="TestTableName" value="DUAL"/>
<set attribute="URL" value="jdbc:oracle:thin:#${env.MACHINE}:1521:NOTXE"/>
<set attribute="Targets" value="${x}" />
</create>
<create type="JDBCDataSource" name="cmifsDBDS" >
<set attribute="JNDIName" value="jdbc/cmifsDBDS"/>
<set attribute="PoolName" value="cmifsDBPool"/>
<set attribute="Targets" value="${x}" />
</create>
</wlconfig>
</target>
Everything works good, until I try to retrieve an ARRAY from DB. I get the following error:
java.lang.ClassCastException: weblogic.jdbc.wrapper.Array_oracle_sql_ARRAY cannot be cast to oracle.sql.ARRAY
I got the solution for this problem in this link, which says that Wrap Data Types should be set to false for the connection pool. This fixed the problem.
But when I tried to add the attribute to my ant script
<set attribute="WrapTypes" value="false"/>
It doesnt work. I am getting the following error:
Error invoking MBean command: java.lang.IllegalArgumentException: Property Name and value not valid for the MBean. Value false for parameter[WrapTypes].java.lang.IllegalArgumentException: Unable to find the attribute: WrapTypes in the attribute list of the class: JDBCConnectionPool
How to solve this problem?
It seems you use common interface and script executor doesn't understand vendor specific flags in this case. Try to use concrete type. May be weblogic.jdbc.common.internal.ConnectionPool will help you.

Restricting IP addresses for Jetty and Solr

I'm setting up Solr using Jetty. I would like to restrict access to only a few IP addresses. It doesn't seem immediately obvious that this can be done using Jetty. Is it possible and if so, how?
Solr 4.2.1 uses Jetty 8.1.8. Jetty 8 (as noted by jonas789) doesn't support .htaccess. Instead, it uses IPAccessHandler, which doesn't have great documentation available. I had to play with it quite a bit to get it work, so I'm posting an updated solution here.
IPAccessHandler manages a blacklist and a whitelist, accepts arbitrary ranges of IPs, and supports attaching specific URI paths to each white/black -list entry. IPAccessHandler also subclasses HandlerWrapper, which turns out to be important.
The solr app still lives in a WebAppContext (as in Lyndsay's solution), but a WebAppContext is now governed by a ContextHandler, which resides in a ContextHandlerCollection occupying the first handler slot in the server. To stop requests from the wrong IP from getting to the app, we need to wrap it inside an IPAccessHandler somewhere along that path. IPAccessHandler behaves oddly if it's in the wrong spot: I tried inserting it before the context handlers and it gave 403 Forbidden to the wrong machines, threw NullPointerException tantrums with no additional error messages, all sorts of nonsense. I finally got it to work by wrapping the ContextHandlerCollection itself, at the server level.
Go to etc/jetty.xml and scroll to the handlers section. Then wrap the existing ContextHandlerCollection item as follows:
<!-- =========================================================== -->
<!-- Set handler Collection Structure -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<!-- here begins the new stuff -->
<New class="org.eclipse.jetty.server.handler.IPAccessHandler">
<Call name="addWhite">
<Arg>xxx.xxx.xxx.xxx</Arg>
</Call>
<Set name="handler">
<!-- here's where you put what was there before: -->
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
</Set>
</New>
<!-- here ends the new stuff -->
</Item>
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
<Item>
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
Resources:
http://comments.gmane.org/gmane.comp.java.jetty.support/6066
http://wiki.eclipse.org/Jetty#Configuration_Reference
http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax
http://download.eclipse.org/jetty/stable-8/apidocs/org/eclipse/jetty/server/handler/IPAccessHandler.html
I found the solution.
Firstly, extract the contents of solr.war in the example/webapps folder.
Then create a file called .htaccess and place it in the example/webapps/solr folder (the one you just extracted) containing the following:
<Limit>
satisfy all
order deny,allow
deny from all
allow from xxx.xxx.xxx.xxx
</Limit>
In example/etc/ edit the jetty.xml file and comment out the org.mortbay.jetty.deployer.WebAppDeployer part. Then finally create a folder in example/ called contexts (if one does not yet exist) and add a file called solr.xml to it containing:
<Configure id="solr" class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/webapps/solr</Set>
<Set name="contextPath">/solr</Set>
<Call name="setSecurityHandler">
<Arg>
<New class="org.mortbay.jetty.security.HTAccessHandler">
<Set name="protegee">
<Ref id="solr"/>
</Set>
</New>
</Arg>
</Call>
</Configure>
Then start up your new secure solr!

Resources