Monday, 29 July 2019

Display Thumbnails for Popular Posts in Blogger

I wanted to show thumbnails in my Popular Posts and I achieved this by using CSS.

Prerequisites:
The Popular Posts widget must be added to the Sidebar in your Blogger template.
Posts have a featured image. In Blogger, this is generally the first image in the post's HTML content. My featured image is 550px by 550px.
Post title and image thumbnail must be checked on the widget configuration options.

Configure Popular Posts



Modify the code below and replace #sidebar-right-1 with the name of your right sidebar section and replace #PopularPosts1 with the name of your popular posts widget/gadget.

Search for  </head> and paste the CSS below just above  </head>
The CSS
 <style type='text/css'>  
   #sidebar-right-1 #PopularPosts1 ul{padding:0;margin:0;}  
   #sidebar-right-1 #PopularPosts1 .item-thumbnail a{clip:auto;display:block;height:auto;overflow:hidden;}  
   #sidebar-right-1 #PopularPosts1 .item-thumbnail{width:130px;height:130px;border-right:5px solid #fff;margin:0px 10px 0px 0px !important;position:relative;}  
   #sidebar-right-1 #PopularPosts1 .item-thumbnail img{position:relative;height:auto;width:100%;padding:0;}  
   #sidebar-right-1 #PopularPosts1 ul li{float:left;margin-bottom:5px;max-height:130px;min-width:250px;overflow:hidden;}  
  #sidebar-right-1 #PopularPosts1 ul li:first-child{background:#E7717D;}  
   #sidebar-right-1 #PopularPosts1 ul li:first-child + li{background:#C2CAD0;}  
   #sidebar-right-1 #PopularPosts1 ul li:first-child + li + li{background:#E7717D;}  
   #sidebar-right-1 #PopularPosts1 ul li:first-child + li + li + li{background:#C2CAD0;}  
   #sidebar-right-1 #PopularPosts1 ul li:first-child + li + li + li + li{background:#E7717D;}  
   #sidebar-right-1 #PopularPosts1 ul li:first-child + li + li + li + li + li{background:#C2CAD0;}  
   #sidebar-right-1 #PopularPosts1 .item-title{font:13px &#39;Arial&#39;, sans-serif;text-transform:capitalize;padding:5px 2px 5px;}  
   #sidebar-right-1 #PopularPosts1 .item-title a{color:#000;text-decoration:none;}  
   #sidebar-right-1 #PopularPosts1 .item-snippet{font:13px &quot;Times New Roman&quot;,Times,FreeSerif,serif;padding-right:5px;}  
   #sidebar-right-1 .#PopularPosts1 .widget-content ul li{padding:0px 5px 0px 0px!important;}  
 </style>  

The :first-child CSS pseudo-class represents the first element among a group of sibling elements. In this case, it targets the first popular post in my list, li:firstchild.
To prevent my popular posts thumbnail from being pixelated I changed the following statement
 <b:with value='data:post.featuredImage.isResizable ? resizeImage(data:post.featuredImage, 72, &quot;1:1&quot;): data:post.thumbnail' var='image'>  
to
 <b:with value='data:post.featuredImage.isResizable ? resizeImage(data:post.featuredImage, 550, &quot;550:550&quot;): data:post.thumbnail' var='image'>  
The images in my post are 550px x 550px.

Thursday, 18 July 2019

How To Use Java Architecture for XML Binding (JAXB) in IIB

JAXB enables IIB via the Java Compute Node to work with a model of message data as Java object classes. This Java object model can be accessed and manipulated by using getter and setter methods.

In IIB Toolkit import the XML schema into your application.

Create a message flow with a JavaCompute node, select the Process via Java Architecture for XML Binding (JAXB) class template.

Click Finish.

Select a Message Model Schema file or container with schema from which JAXB Java Object Classes will be generated. Select option to Generate JAXB Java Object Classes from Message Model Schema for us in the Java Compute Node Class.


Type the Java Target Source Folder and the Target Java Package and click Finish.
Accept the default values on the next screen and click Finish.

The JAXB Java object classes are visible in the Application Development view, under the JaxbAppJava(in my case) source folder of the Java project that you selected in the wizard.


The next thing to do is to process the message body data by using JAXB Java object classes, the JAXB Java object classes are a Java object representation of your message.


The code below shows some JAXB code that reads a record from the payload using a getter method.

Monday, 24 June 2019

Publish/Subscribe

Publish/subscribe is a style of messaging application in which the providers of information (publishers) have no direct link to specific consumers of that information (subscribers), but the interactions between publishers and subscribers are controlled by pub/sub brokers.

In a publish/subscribe system, a publisher does not need to know who uses the information (publication) that it provides, and a subscriber does not need to know who provides the information that it receives as the result of a subscription. Publications are sent from publishers to the pub/sub broker, subscriptions are sent from subscribers to the pub/sub broker, and the pub/sub broker forwards the publications to the subscribers.

Publish/Subscribe is a term used to define an application model in which the provider of some information is decoupled from the consumers of that information.

A typical publish/subscribe system has more than one publisher and more than one subscriber. An application can be both a publisher and a subscriber.

New providers/consumers can be added without disruption

The publisher generates a message that it wants to publish and defines the topic of the message. A subscriber registers a request for a publication by specifying the topic (or topics) of the published messages that it is interested in. Subscriptions to an MQ pub/sub broker might include the following information:
The subscription point from which it wants to receive publications.
The content filter that should be applied to the published message.
The name of the queue (known as the subscriber queue) on which publications that match the criteria selected are placed. This queue can be a cluster queue, so that publications can be distributed to clustered subscribers.

Publishers provide information about specific topics by sending publications to the queue manager. MQI publishers use the MQPUT verb
Subscribers register subscriptions with the queue manager to indicate their interest in information relating to specific topics. MQI subscribers use the MQSUB verb

The queue manager forwards each publication it receives to all subscribers with a subscription which matches the associated topic


In the compute node set the message type to publish and topic name, before you pass it to the Publication node.

SET OutputRoot.MQRFH2.psc.Topic = '/data/v1';
SET OutputRoot.MQRFH2.psc.Command = 'Publish';

In WebSphere MQ Explorer create the topic '/data/v1'



In WebSphere MQ Explorer create a subcription, subscriber1


I will then create a subscriber flow which will read messages from the test queue.

Tuesday, 18 June 2019

Configuring Email Nodes to Receive and Send Emails using Office365 Mailbox in IBM Integration Bus


Enter the following commands to enable IBM Integration Server to use secure POP.

mqsichangeproperties <Integration Node> -e <Integration Server> -o HTTPSConnector -n sslProtocol -v TLSv1.2

mqsichangeproperties <Integration Node> -e <Integration Server> -o ComIbmJVMManager -n jvmSystemProperty -v "-Dmail.smtp.starttls.enable=true -Dmail.smtp.auth.enable=true"

mqsichangeproperties <Integration Node> -e <Integration Server> -o ComIbmJVMManager -n truststoreFile -v <path to trust store file>

mqsichangeproperties <Integration Node> -e <Integration Server> -o ComIbmJVMManager -n truststoreType -v JKS

mqsichangeproperties <Integration Node> -e <Integration Server> -o ComIbmJVMManager -n truststorePass -v brokerTruststore::password

mqsisetdbparms <Integration Node> -n Intermittent::truststorePass -u ignore -p <trust store password>

mqsichangeproperties  <Integration Node> -e <Integration Server>  -o ComIbmJVMManager -n keystoreFile -v <path to key store file>

mqsichangeproperties  <Integration Node> -e <Integration Server>  -o ComIbmJVMManager -n keystoreType -v JKS

mqsichangeproperties <Integration Node> -e <Integration Server> -o ComIbmJVMManager -n keystorePass -v Intermittent::keystorePass

mqsisetdbparms <Integration Node> -n <Integration Server>::keystorePass -u ignore -p <key store password>

mqsisetdbparms <Integration Node> -n email::securityIdentityName –u myEmailServerUserID  -p 'myEmailServerPassword'

Stop and restart the integration server.

Tuesday, 26 March 2019

Good IIB ESQL Coding Practices

Array Index Notation
Avoid traversing the elements in sequence, starting from 1, until n is reached for every iteration of the loop. Instead, use a reference variable and the MOVE NEXTSIBLING syntax.

For a loop of 100 elements, index access notation results in 5000 (50 x 100) element traversals instead of 100 with the MOVE statement (50 times more). For a larger list of 1000 elements, it is worse; 500000 (500 x 1000) traversals instead of 1000 (500 times more).

Example of using reference variables

 DECLARE empRef REFERENCE TO OutputRoot.JSON.Data.Employee.Item[1];  
 WHILE LASTMOVE(empRef) DO  
  empRef.Name = 'John Smith';  
  MOVE empRef NEXTSIBLING;  
 END WHILE;  


Cardinality Function
The following guidelines apply to using this function:

  • Don't use it to set an iterative limit on a loop that then uses array index notation.
  • Don't use it to count the number of elements in a large, unparsed file since this will likely cause an abend.
  • Don't use it to test for the existence of an element


Tree Access Order and Path References
Message trees are a complex data structure that behave much like a doubly linked list.
Ways to optimize performance include:

  • locating often referenced items near the top of a child list
  • defining reference variables for complex element paths in order to avoid repeated evaluations
  • avoid generic recursive tree walks.


Use XMLNSC for XML Processing
XMLNSC is the most efficient XML parser in IBM® Integration Bus. Use it in preference to MRM and other XML parsers

Minimize Message Flow Node
Try to avoid chains of compute nodes in a simple msgflow that could be easily combined into one node.

Source: IBM © Integration Bus Information Centre

Tuesday, 12 February 2019

Accessing a User Defined Configurable Service in Java

A UserDefined configurable service is accessible by the JavaCompute Node node only, and cannot be accessed by ESQL.

I created a UserDefined configurable service with the following values:

EmployeeDetails
EmployeeNumber:  O0001
EmployeeName:  James Ndlovu
Department:  IT
City: Johannesburg


In the LocalEnvironment set the EmployeeNUmber in Variables/EmployeeNumber which I want to use to retrive the Employee Details from the config service.

To create the Java code, right-click the JavaCompute node and click Open Java to create and open a Java™ file in the Editor view.
Create the Java class for the node in which you want to include IBM Integration API methods.
Add the IBM Integration API JAR file install_dir/common/classes/IntegrationAPI.jar to the Java build path for the associated Java project.

Import com.ibm.broker.config.proxy.* in your code.


try { // create new message as a copy of the input MbMessage outMessage = new           MbMessage(inMessage); outAssembly = new MbMessageAssembly(inAssembly, outMessage); /*get   employee details from local environment variable */
 MbMessage localEnv = inAssembly.getLocalEnvironment(); 
 MbElement empNoVar =     localEnv.getRootElement().getFirstElementByPath("Variables/EmployeeNumber"); 
 String employeeNumber = empNoVar.getValueAsString(); 
 BrokerProxy b = BrokerProxy.getLocalInstance(); /*return an instance of the BrokerProxy object for the integration node to which the message flow (that contains this node) is deployed */
 while (!b.hasBeenPopulatedByBroker()) 
 { 
   Thread.sleep(100); /*This ensures that the BrokerProxy object is populated with data from the integration node before you access the configurable service */
 } 
 ConfigurableService vendorUDCS = b.getConfigurableService("UserDefined", "EmployeeDetails"); 
 String employeeDetails = vendorUDCS.getProperties().getProperty(employeeNumber); /*output the employeeDetails to a local environment variable*/
 MbMessage newEnv = new MbMessage(localEnv); newEnv.getRootElement().createElementAsFirstChild(MbElement.TYPE_NAME_VALUE, "EmpDetails", employeeDetails); 
 outAssembly = new MbMessageAssembly(inAssembly, newEnv, inAssembly.getExceptionList(), inAssembly.getMessage()); 
b.disconnect();

catch (MbException e) 
{ // Re-throw to allow Broker handling of MbException throw e; }

Friday, 25 January 2019

Creating WebSphere MQ Objects

Below are some commands for creating mq objects.
Use the DEFINE QLOCAL to create a local queue
DEFINE QLOCAL ('myqueue') +
       DESCR('my test queue') +
       PUT(ENABLED) +
       DEFPRTY(0) +
       DEFPSIST(YES) +
       DEFPRESP(SYNC) +
       SCOPE(QMGR) +
       GET(ENABLED) +
       PROPCTL(COMPAT) +
       DEFREADA(NO) +
       MAXDEPTH(999999999) +
       CLUSTER(' ') +
       CLUSNL(' ') +
       DEFBIND(OPEN) +
       CLWLRANK(0) +
       CLWLPRTY(0) +
       CUSTOM('capexpry(25920000)') +
       REPLACE

Use the DEFINE QALIAS to create an alias queue
DEFINE QALIAS ('myaliasq') +
DESCR('My alias queue') +
PUT(ENABLED) +
  DEFPSIST(YES) +
SCOPE(QMGR) +
        GET(ENABLED) +
TARGET ('REMOTE QUEUE')

Use the DEFINE QREMOTE to create a remote queue
DEFINE QREMOTE (REMOTE QUEUE) +
DESCR ('Remote Queue') +
RNAME (REMOTE QUEUE) +
RQMNAME (QMGR1) +
XMITQ (XMIT1)

You can save the commands in a text file.
Use the runmqsc command to issue MQSC commands to a queue manager.

runmqsc QMGR  <  C:\Temp\MQ_Objects.txt > C:\Temp\result.txt

The above command will invoke the MQSC commands in the text file against the QMGR queue manager. The result is sent to result.txt.

From WebSphere MQ veriosn 8.0.0.4, a new attribute CAPEXPRY has been introduced that can be used to alleviate problems of messages building up and hitting maximum depth limits. Setting this attribute on a destination means that when a message is put to that destination, the expiry time of the message will be limited to the value set in CAPEXPRY.