In a mortar and pestle, lightly crush juniper, allspice, coriander and peppercorns. Place crushed spices in a medium saucepan and add chilies, shallot, bay leaves, star anise, vinegar, water, sugar and salt. Bring to a boil. Reduce heat to a gentle simmer and cook for 5 minutes, stirring occasionally.
Peel the outermost layer of the rhubarb, using your fingernails or a paring knife. Then, cut the rhubarb into 4-inch lengths, so it’s about 1 inch shorter than your jars when upright. If the stalks are thick, halve or quarter them lengthwise so they are about ¾ inch thick.
Pack the rhubarb snugly into 2 clean 1-pint canning jars.
Fill the jars with the hot liquid and spices. Cover the jars and refrigerate for at least 1 week and up to 2 months, before eating.