  A semigroup $\langle C\rangle$ in $\mathbb{N}^n$ is a gluing of $\langle
A\rangle$ and $\langle B\rangle$ if its finite set of generators $C$ splits
into two parts, $C=k_1A\sqcup k_2B$ with $k_1,k_2\geq 1$, and the defining
ideals of the corresponding semigroup rings satisfy that $I_C$ is generated by
$I_A+I_B$ and one extra element. Two semigroups $\langle A\rangle$ and $\langle
B\rangle$ can be glued if there exist positive integers $k_1,k_2$ such that,
for $C=k_1A\sqcup k_2B$, $\langle C\rangle$ is a gluing of $\langle A\rangle$
and $\langle B\rangle$. Although any two numerical semigroups, namely
semigroups in dimension $n=1$, can always be glued, it is no longer the case in
higher dimensions. In this paper, we give necessary and sufficient conditions
on $A$ and $B$ for the existence of a gluing of $\langle A\rangle$ and $\langle
B\rangle$, and give examples to illustrate why they are necessary. These
generalize and explain the previous known results on existence of gluing. We
also prove that the glued semigroup $\langle C\rangle$ inherits the properties
like Gorenstein or Cohen-Macaulay from the two parts $\langle A\rangle$ and
$\langle B\rangle$.
