I need to send MT950 messages to a SWIFT message, I've done this before but I always forget how I did it. This version, however needs to be a little more comprehensive. Specifically, I want to develop this to send messages from a query, but be able to map the query results to the message fields so first things first I'm going to need to tool up. I downloaded Apache Active MQ and installed it (basically just uncompresses)
The above starts Active MQ. In a web browser, navigating to http://localhost:8161/admin/index.jsp you should see the following
So now we've got something to send a message to we can code up a simple test. here's my pom: 4.0.0 cwc SwiftMessagePublisher 1.0.0.BUILD-SNAPSHOT jar SwiftMessagePublisher http://www.springsource.org/spring-integration
2.2.1
UTF-8 2.2.4.RELEASE 1.2.17 4.11
repo.springsource.org.milestone Spring Framework Maven Milestone Repository https://repo.springsource.org/milestone
Create a project and add this in eclipse. Here's mine...
I've used STS here and created a Spring project. I added maven and modified the POM. You need a couple of alternative repos because some of the dependencies aren't covered by the defaults. notice the spring integration context. STS adds this for a Sprint Integration project by default.
You'll notice the testSend() :void test. I added this just to get the go-no-go test proved with Active MQ. Here's the code, no spring in there yet. I just want to prove that I can successfully send a message to the Queue.
@Test
publicvoid testSend(){
try {
//created ConnectionFactory object for creating connection
ConnectionFactory factory = new ActiveMQConnectionFactory("admin", "admin", "tcp://localhost:61616");
We're good, all compiles and runs.. but did we send a message?
Switch to the ActiveMQ Console and review Queues. Click the queue name and you'll see there's a message. Click the message to review the payload and we can see we've got a "Hello World" message.
OK so to review, we've installed Apache Active MQ, retaining the defaults. Created a Spring Integration Project in STS (Spring Source Tool Suite) and added a test that sends a hello world message to Active MQ. We've tested the development harness and we're ready to start generating and testing SWIFT messages. ...not bad for a hour or so's work.
Avoiding concurrency issues in stored procedures can be tricky. I'm writing some functionality to add a document ID to a table in Oracle. The requirement is as follows:
The document ID must consist of a string identifying the entity a string identifying the month and a string identifying the year and an increment.
[entity]_[mm]_[yyyy]_[nnn] which might look like 9999_01_2017_1
At first glance this looks like it should be quite easy. query the data by entity, month, year. count and add one. Cast the numeric values to a varchar and Concatenate. This, however doesn't take into account the fact that two concurrent inserts might not see a unique count. In this case you'll end up with the, possibility disastrous, duplicate. This is the scenario that DBMS_LOCK was designed to resolve.
For me the solution was to employ the example here
This very good article clearly shows how to lock a portion of pl/sql while an update is carried out and then release the lock such that the process remains isolated and gets an unimpeded view of the data it's updating and can remain confident that the process will function without concurrency issues.
BEGIN -- Calculate the document id DBMS_LOCK.allocate_unique( 'SET_APPROVAL_DOCUMENT_ID', v_lock_handle ); v_call_status := DBMS_LOCK.REQUEST(v_lock_handle, DBMS_LOCK.X_MODE, 5, TRUE); IF v_call_status = 0 THEN Select ( select to_char(je.legal_entity_cd)||'_'||je.financial_period from me_journal_entry je where je.CFME_ID = p_cfme_id) ||'_'|| ( select to_char(count(*)+1) from V_ME_JOURNAL_APPROVAL_LOG al, (select je.legal_entity_cd, je.financial_period from me_journal_entry je where je.CFME_ID = p_cfme_id) j where al.is_approved = 'Y' and j.legal_entity_cd = al.legal_entity_cd and j.financial_period = al.financial_period) into v_doc_id from dual;
Today, My eldest daughter showed me her school blog. At eight she's learning how to blog. The school has subscribed to a bolgging site for schools. In this day and age of the internet, shouldn't the school have it's own Wordpress site? Installation literally takes minutes. Keeping it internal would make it safer and give the school full control over the site. I've set up a few Wordpress sites now and it's so easy. I installed Wordpress on a hosted Centos machine using this fantastic tutorial Wordpresss installation
Clever chaps & chapesses at Google. I've just put a website live for an Accountancy Outsourcing Company www.henryjamesoutsourcing.co.uk and added Google Analytics to the site.
Google Analytics is one of a number of tools Google provide for web developers. Essentially it captures statistics for pages on your web site. You have to have a Google account to use it so you have to sign up there first. Then you add Analytics to your suit of Google tools (sign up for an email address whilst you're at it and you can receive your stats reports pushed via email to the google email address)
Once you've signed up you'll get a little text window with some Java script in that'll look a bit like this
Copy this and paste it into your static web pages eg index.html … before the tag (keeps things tidy) and that's it hit your site a few times and check your Analytics pages a bit later (takes a while for the stats to filter through) I hit the verify
Now for some techie stuff: This is downloading some javascript code from google that actually does the monitoring. It uses cross site scripting to do this but adding the javascript dynamically
gets round the browser security issues (see my earlier posts on cross site scripting and Ajax) Activity is reported back to google in most cases. One thing to watch out for is that any activity from China won't be reported on in full because of Chinese Government security limitations on internet information. Not that that's a problem for Henry James Outsourcing, maybe for when we're a little nearer world domination.
Search Engine Optimisation - a strange and dark world occupied by people with street cred. games consoles and skateboards. I was contacted recently by a company I did some work for because searching for their name and one of their customer's brought up all the usual sites in google and my CV (woops!)
The CV was a pdf, and listed companies I had done work for although there was no direct link in the wording my CV obviously listed my client but also their customer mentioning no link or relationship.
I took the CV down for the sake of a quiet life, but it got me thinking why didn't my company website show up in the same search? http://www.cwebster-consulting.co.uk/. This in turn started me thinking about SEO (Search Engine Optimisation), something I'd not done for a long time. It dawned on me that the last time I did anything along those lines was way back when, all you had to do was drop in the key words in the meta tag and send a cheque off to your favourite search provider!
Now though, it seems things have changed. I'm reliably informed there are “White Hat” strategies that can get you to the top of the list. There are “Black Hat” strategies that can also get you there but can also get you barred from search engines altogether. You're best going to an SEO specialist Dave Chung is one SEO Guru who can help you to get your site a more appropriate audience.
So what strategy did I use to get my CV up there in the rankings? Well, none what so ever. It was a pdf, so there was no code. There were no links (I'm not that great at creating pdf's) it was just a CV exported from Word to pdf format. It did for some reason though, satisfy whatever criteria Google use to rank web pages. I can only assume that this is simply what's in the text.
I did a little more digging and came up with Google’s rules on getting good page ranking. Some interesting things come up. For example, every web page has a reputation. Websites with a good reputation linking to other well behaved websites improve their page rankings. So don't link to iffy websites and do link to legit, nice websites and let them link to you. One of the “Black Hat” strategies is to set up a company and charge people for links to bump up their ranking. Be careful, though, if discovered this can get you banned from some sites including Google.
Nice sites that show meaningful error messages (401, 403, 404, 500 errors) instead of the default pages churned out from standard web servers rank higher. So customise your error messages and give links back to the main pages in your site from the error pages.
Only three things matter on websites, content, content, content. For your site to bump up its rankings you need to publish articles that are relevant to your business. Use Title text as though it were key word searchable. Google like to use titles as guides to what's on the site. So for example if you’re a plumber you should add an article every month on Plumbing, Plumbing techniques, Plumbing products, maybe review some equipment. This will aid the search engines indexing of your site for relevant key words in the search criteria.
Finally update regularly, most search engines throw relevance into the mix by returning sites that are regularly updated and maintained. This shows a site on the move and being kept up to date. All of which adds to relevance.
I'm building a MySQL Driven web app using MySQL JPA Hibernate JConnector. I've hit an exception: HTTP Status 500 - exception javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: could not load an entity: [net.bmo.model.BmoCalendar#2]
The root cause of this error is: root cause:java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
Basically this means that the DB connection times out and when the app. went back to the DB to retrieve some data the connection had been lost.
Solution? Add connection pooling. Something I'd been meaning to get round to but hadn't had a chance. So I added C3P0 Connection pooling. I'm using Hibernate so I added the following dependency to the pom.xml: <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-c3p0</artifactId> <version>3.3.2.GA</version> </dependency>
This drops in the required jar(s) hibernate-core-3.3.8.GA.jar and c3p0-0.9.1.jar add them to the class path if you don't already have them.
Next I added the c3p0 properties to the persistence.xml file. The amendments are highlighted in blue. <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="myPersistence" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence <properties> <property name = "hibernate.connection.driver_class" value = "com.mysql.jdbc.Driver"/> <property name = "hibernate.connection.url" value = "jdbc:mysql://localhost:3306/myDB"/> <property name = "hibernate.connection.username" value = "uid"/> <property name = "hibernate.connection.password" value = "pwd"/> <property name = "hibernate.hbm2ddl.auto" value = "validate"/> <property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider" /> <property name="hibernate.c3p0.max_size" value="100" /> <property name="hibernate.c3p0.min_size" value="0" /> <property name="hibernate.c3p0.acquire_increment" value="1" /> <property name="hibernate.c3p0.idle_test_period" value="300" /> <property name="hibernate.c3p0.max_statements" value="0" /> <property name="hibernate.c3p0.timeout" value="100" /> </properties> </persistence-unit> </persistence>
The effect of the lines above is to force the test of the connections in the pool at regular intervals and refresh the connection if required. This prevented the above error for my deployment. I did this without making any changes in the MySQL Database configuration
I met a guy the other day who was having a bit of difficulty with his company's IT infrastructure. If I had a pound for every time I have this conversation.
"We've got xxx application running on a server in our office and it's broken/not doing what we want any more. Can you fix it?"
Well, yes, probably. But how do companies with no IT expertise end up with huge systems flogged to them by some bloke they knew then he left/went bust/went elsewhere and now we're high and dry with no IT resources.
Also, why does someone recommend MS Small Business Server and MS Exchange to an organisation that clearly don't have the resources to maintain it? At some point the underlying SQL Server will run out of space/run into problems emails will get inevitably get lost and the whole thing will fall apart. It happens at big companies (I've seen it!) and can cause all sorts of issues, but it can cripple a small organisation.
These are the same organisations that don't get a consultancy in to give them a realistic breakdown of the the options and costs. I'd want to see 3 or 4 different options and cost/benefits for each and make my mind up from there. There's no doubt that there are a lot of clever systems out there with lots of features but they all come at a price and maintenance is no small part of that price.
I'm not saying that consultancy is a solution in itself, far from it. In the UK Business Link can be a good source of advice as well as numerous other organisations. There's a range of issues to consider when buying an IT system. Hardware failure support, software training support, procurement, installation & deployment, maintenance & disposal. Having seen a few RFP's (Request For Proposal) usually issued by very large companies to invite bids from suppliers. This seems a good way for small businesses to think too. If nothing else it forces the purchaser to consider the requirements as a whole rather then just as buying a shiny sparkly new computer that looked great in the add. A little bit of light research will show up RFP examples and guidance
This company I spoke to could have achieved all they wanted (email, shared docs & calendars, holiday forms linked to storage and basic work flow) from Google Apps for example or any number of other systems and it wouldn't have cost him the best part of 6k GBP and he wouldn't be high and dry when it went wrong.
In this case SAAS(Software As A Service) services (or ASP - Application Service Provision - as it used to be known) could have a real benefit. YOU don't have to have a DBA and a Sys Admin on your books. There's plenty of time and scope to bring that in house as and when you're big enough. But please don't "get a bloke you know" to do it for you unless he's prepared to enter into an SLA(Service Level Agreement) and can provide you with a DR strategy for when he gets hit by a bus.
I'm blogging this as much for my own use as help for other's.
Every time I set up a new Tomcat server I forget these options! Once you find them keep them safe.
set JAVA_OPTS=-Xms256m -Xmx1024m -Xss96k -XX:MaxPermSize=512m -server -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
It's the CMSClassUnloadingEnabled that prevents the OOM error. The memory options depend on your hardware.
To set these options for the Sand Box Server in eclipse goto window -> preferences. In the left hand view select servers click on the tomcat server and add the above to the startup options. I'd post a screen shot but I'm using MyEclipse which is a bit niche for most developers.
I was asked to get an online payment system working recenlty but the site was hosted away from the customer's site. Payment confirmation was on the customer's site and payments were run from WOLRDPAY. So my problem was how do you get the page to not accept payment twice for the same invoice? Answer a payment check service using ajax returning a simple paid/not paid response to the invoice id in the request. But in AJAX you can't do that because you're stepping off your domain.
Eventually I found JSON-P according to the browser implementation of XMLHTTPRequest the URL needs to be relative ie /ajax/CheckInvoice?invId=12345 I wanted http://some3rdpartysite/CheckInvoice?invId=12345
JSON is a way of encoding the XML request into key-value pairs but JSON-P adds a call back function that is created locally the AJAX request then looks at the local call, the local call wraps a function that calls the remote site. The Browser is not then aware of the cross domain aspect of the call and doesn't throw an exception. Job done, customer happy.
I'm not, though. Unfortunately there is some disagreement around whether or not this is a legit process. Many developers think that because JSON-P takes advantage of the fact that <script> tags are not evaluated, this is in fact a security flaw and should be plugged. So will my solution be broken by a future browser release? There is another school of thought that this is, in fact a legitimate process - certainly in this case, that should be handled appropriately and that until browser technology catches up JSON-P is a legit solution.
I agree with the latter. In my case the sites are all legitimate and it is simply a case of integrating two SAAS (Software As A Service) Services and that's becoming ever more important. The fact that they haven't been built to provide these services formally is more to do with the implementation rather than the principle.
Tuesday, 23 June 2009
Microgen Aptitude®
Having worked with Microgen Aptitude® development tool whilst employed by Microgen® I naturally included it on my CV. However, every time I go to an interview for a new contract I get asked “What is Microgen Aptitude?” and have to explain exactly what it is and why it's relevant to my work as a developer.
Microgen® is a Software Consultancy & Supply organisation focussing mainly on, but not limited to, the financial sector.
Aptitude® is described as "The Enterprise Class Business Process Management Suite" essentially a piece of software that allows you to define the data in your business and your organisations rules for processing that data. You can use the rules you create to generate business processes based on those rules and run those processes in an ordered manner. Including all the tools & facilities you've come to expect from an enterprise level development environment.
Data exists within an organisation in a number of forms Databases, files, message feeds etc. Aptitude® caters for all the common formats and has facilities for transforming these sources to Data Objects which can then be used to create rules.
This is interesting but nothing new. I can model my business objects in Java and map those objects to a Database schema using a ORM (Object Relational Mapping) tool like Hibernate Aptitude®, however, does this using a graphical development environment, which allows you to drag and drop entities around the development environment.
fig. 1 An example rule
fig. 2 An example of a business process designed with a source, rule, and target entities.
Graphically representing the elements of a business process gives a visual representation of the rules involved in a business process which, in turn, contributes to a better understanding of the rules and processes required to make business decisions. Not only this but there is no need to learn a complex 3rd generation programming language. Microgen® suggest that this tool can be used by a Business Analyst, however I, personally wouldn't go that far. You still need to have a strong technical understanding of software development to use Aptitude® efficiently. Not least because you'll more than likely be using it in conjunction with a database of some sort and that means an understanding of the Relational Model at least. Then there's understanding XML, messaging, SOA, Transactions processing, file formats.
The next most significant part of the Aptitude® suite is the ability to then use the it's built in Web interface designer. I'm not going into much detail in this article, but at a high level you can design a web page and deploy it to IIS or Tomcat in the more recent incarnations. Looking a little like a Visual Basic style form designer, the design interface lets you drag and drop web widgets onto a 'page' and connect them to your Business Processes or Reference Objects. Once deployed you have a working web interface that can deliver functionality around your organisation based on a common set of business rules.
Pros: Graphical development environment, wizards to rapidly model existing objects from table/file specification, security model, test/debug environment, Cons: Single vendor, fixed device interfaces, limited after market consultant base, slow costly development cycle, maturity.
Conclusion If you've got the money, Aptitude® is a nice tool. Out of reach to all but the most well off organisations, however, as technologies like this become more popular and competition in the market place increases this may change.
Attended a new networking organisation B49 (before Nine!) run by Nick Lofthouse keyfins.co.uk and his business partner. The group is a support and referral organisation and I've already benefited from help with invoicing, office space and contacts.
The group is located at Welwyn Garden City Golf Club and meets on a Tuesday from Seven Am until Nine
I met Matt from 3internet, great chap, even if he is a .NET guy ;)
They have a nice site, and do all sorts of MS based Web Applications including design and content management.
Wow it's been ages since I updated the Blog. I've been working hard for Microgen on a new Billing portal for Virgin Media (ntl:Telewest Business). It was an awesome project. In Four months we re-wrote the online billing application that they'd inherited through an acquisition.
Now it's leaner and meaner. User admin functionality, self sign-up, still with full integration with Microgen'seBilling architecture only now the load process is more maintainable and leveraging JSF, Spring, JPA & Hibernate, we managed to produce a lovely RIA. Only draw back is the configuration nightmare that was the project inception. So what next?
There's a phase II that I may or may not be involved in because I've got other projects to work on, although I'd love it if I could be part of it but Microgen is back up to strength in that department so maybe consultancy only.
I've been investigating other alternatives in the RIA market place. Currently I'm messing with Google's App Engine which I love, with GWT. I played with flex but there are issues there with page ranking, and forcing customers to use Flash - not a bad thing in itself but some people registered protests about moving away from vanilla web (silverlight? JavaFX?)
Back to the blog after a nice family holiday at Bosinver Farm Cottages. A week in the west country 'on the farm' my eldest learnt to eat eggs, feed ducks, chickens and Chalky the Goat!
Getting back to the office, we're ramping up the design work on the new eBilling system. It's looking great. So much simpler than the existing system.
I've been evaluating charting tools for Java web apps. I've got a bit of a problem though. What ever we choose has to be used by the old struts I app. and the new JSF system. Hmmm that says mashup to me. use an ajax plugin. I found a java project that wraps flash - handy. Flash interactive animated charts inside a java web app. really though I should wait for JavaFX or maybe I could do something in Flex with a webservice.
Also I've finally got around to updating my web site to link into this blog. A bit of joined up thinking!
I found LinkedIn too not sure how useful it is - a sort of Facebook for grownups. I thought I'd take a look and then I found most of the people I work with on it and all this time I didn't know. How left out do I feel? Erm not much really.
I signed up for an Oracle BI hands on day in London and then got a call from a nice lady at Oracle saying we've over subscribed and could we bump you to a later date. 'Yes' I said, because it clashed with a family commitment. We'll contact you at a later date with a new date. I've still not heard anything. Hey guys if you can't do it don't advertise it. Now maybe I'm wondering what else Oracle says it can do that it can't really!
I've always avoided using javascript. I truely hate javascript. Having said that I recenlty found myself having to add a tabbed section to a web page and I really could not be bothered to mess about. So I turned to Ext javascript tools library. It really made a nasty job actually quite easy. I was using the TabPanel, a couple of lines of code from the very good api example got me up and running and the resulting table showed good browser compatability.
write the javascript, include the required library files and stylesheets in the html page and off you go....
Ext.onReady(function(){ // basic tabs 1, built from existing content var tabs = new Ext.TabPanel({ renderTo: 'tabs1', width:620, activeTab: 0, frame:true, border:true, defaults:{autoHeight: true}, items:[ {contentEl:'tab1', title: 'Originating Number(s)'}, {contentEl:'tab2', title: 'Recurring Charges'}, {contentEl:'tab3', title: 'Cost Centre(s)'} ]] });
function handleActivate(tab){ alert(tab.title + ' was activated.'); } });
Then in my HTML page.... <div id="tabs1"> <div id="tab1" class="x-hide-display"> <p> tab1 text here... </p> </div> <div id="tab2" class="x-hide-display"> <p> tab2 text here... </p> </div> <div id="tab3" class="x-hide-display"> <p> tab3 text here... </p> </div> </div>
Job done. comes all styled up and looks great.
You can mess with the options available in the API and take it from there.
Just got back from a training course on the above. Very cool. I really enjoyed it. Having used Struts for years I've always been irritated that MVC architecture was a complicated as it was. It never really felt as though it had been given the attention it required. JSF on the other hand feels like MVC the way it should be. Navigation rules are simple and obvious. Some people suggest that there's little difference between Struts MVC and JSF. At first glance I agree it does seem that the difference isn't very great. You really notice it when you develop in JSF in production.
I have to say that so far JSF promises a lot but seems under developed, however I'm not sure if this is just my lack of knowledge. So I went out and bought the book "Core Java Server Faces" Prentice hall. Which basically says how to do all the good stuff that wasn't in the course!
Now JSF is officially part of JEE it's popularity is sure to increase faster than ever.
EJB3.0 was a vast improvement on previous EJB versions. I took a look EJB 2.0 a while ago but the overhead was so vast that we deemed it too heavy for our requirements. Now I think that's changed. Although I don't have need of most of it's attributes. If/when I start dealing with more distributed transactional systems I'll certainly re-evaluate EJB as a possible solution.
JPA - great as ever really simplifies the persistence process
Last Wednesday (16th April) saw the 36th London Java Web User Group get together. The subject for discussion was JBoss SEAM described admirably by Sebastien Degardin, his English being much better than my French!
The upshot of the evening was that SEAM a framework for developing web applications can quickly produce usable web applications - the API being open source, the dev environment might cost if you go to JBoss and get their dev IDE.
The best thing Sebastien demonstrated was that SEAM could automatically reverse engineer a CRUD web application from an existing database schema pointing the IDE at a database resource the application then generates all the necessary pages and persistence architecture based on Hibernate. Although SEAM has it's own it was written by the same guy who did Hibernate. The web interface is built using JSF which, in this version, now hides all JSP and simply uses tags in a similar way to wicket. It effectively means that you're using web components instead of coding HTML.
One nice feature of SEAM is the way it manages session data, we all know about the application context and the session context in web applications. SEAM however, introduces the concept of a "Conversation", such that if you need to store session data across multiple interactive sessions that can be done. Think of an application such as an online auction, you might want to share bid information across a number of sessions spanning a much longer period that a single user session. The "Conversation" concept allows this. I thought that's nice if I have some processing that the user starts but that is completed by an administrator such as signing up a customer and provisioning a service of some kind.
Finally an interesting comment was that, apparently, you can run EJB3.0 in Tomcat. How, when it's not an EJB container? JBoss have an embedded EJB3.0 container. I'm going to look into this further, it's a good one to trick people with but with so many EJB compliant Application Servers I'm not sure why you'd want to. Maybe a phased scaling up of an existing application? There's another one called easybeans which works with java 1.5+ and tomcat 5.5+.
Anyway many thanks to Sebastien for his presentation and to Peter and Evans for organising the event, and "Hi" to Dave Snowdon at ecube who I enjoyed chatting to until I had to dash off for a train.
Interesting one this. I'm sitting here wondering whether to test all my getter and setter methods. Since I let Eclipse do all the work should I test them all? Two theories here. One, Test everything that can go wrong. Two, don't explicitly test them because you'll test them implicitly in the tests for more complex application testing. Further more if I don't use the get/setter in my test code do I need the get/setter in the first place? That's just a bonus.
It seems to me that Scott Leberknight has the right idea. I'd like to see his solution incorporated in JUnit. Then I surfed around and saw that there was some question as to whether get/setters were in fact OO or not. Interesting comments, brighter people than me are suggesting not always. I can see the point. Read the "Why Getter and Setter Methods are Evil" on JavaWorld by Allen Holub and have a think about it.
Now I'm thinking I should revisit the whole thing.
Freelance Software Developer, development laguage agnostic. Experienced in both Open Source and Microsoft software development. Available for Architecture and Infrastructure design and build or consultancy. My background is in Telecoms, Billing Portals, Banking, eCommerce and Security. I like to see things working better as I leave than when I arrived. Progress has been made, Simple.